oh my please help me..i;m making a simple code in c++ using dev c because i am exploring this language for my second year. i do not know why it will not display the output..i don't know how to use cin..

#include <iostream>

using namespace std;

int main()
{
	cout << "Hello World!" << endl;
	return 0;
}

Hi Mavs123,

the dev c doesn't displays the output in the window only...

you do like this
1.after compiling the program in dev c.
2.open the command prompt
3.then go the folder where you have saved the files that has been compiled
4.then just search for your file name with the .exe extension and it will display the output in the command prompt only.

it will work..

add this after your hello world line

cin.get()

or use the header

#include <windows.h>

then add in after Hello World

system("PAUSE");

tnx..

Yes You have to run it Through the Command Prompt.

it will display output through cin.get()..even if i'll go to the command prompt still it will not..

This is a example showing how you use cin

int answer;
cout << "Hello, how old are you?" << endl;
cin >> answer; 
// waits for you to input, what ever you type declares the value of answer!
cout << "So your " << answer << " years old!" << endl;

Note: You can use more than just int answer, like char, strings, ect...

I have been told to stay away from system("pause") instead of using pause, use cin.get();

hey u should use getch() in ur code, so that it will wait at your command prompt to enter any charcter, then u can see your output.try below code it will show the output

#include <iostream>
#include <conio.h>
 
using namespace std;
 
int main()
{
	cout << "Hello World!" << endl;
	getch();
        return 0;
}

cin is user to take input from the keyboard like
cin>>n;
where n is any data type.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.