I typed this program. this program is not displaying the output

#include <stdlib.h>
#include <iostream>
using namespace std;
int main()
{
int x;
std::cout<<"Enter the value of x";

std::cin>>x;

std::cout<<"the value of x"<<x<<std::endl;



}
please help me out to find out the problem.
There's nothing wrong with the program.
closed account (zb0S216C)
Firstly, you don't need the scope resolution operator on the standard namespace, as you already told the compiler you're using it all.

Secondly, main( ) doesn't return a numerical value.

Thridly, <stdlib.h> is a C header, not a C++ header. Instead, use the <cstdlib> header. Actually, you don't even need it in the code you posted.

Does the console shutdown immediately after execution? My guess is that it does. In that case, what you need to do is add cin.get( ) before the return statement. This will keep the console window open, until a key is pressed.

Wazzak
Last edited on
Secondly, main( ) doesn't return a numerical value.
There's two possible interpretations for what you said, but in both cases you're wrong. Yes, it does.
yes my console shutdowns immediately after execution.
Hi everyone, Can some one tell me why exactly we use #include namespace std;
closed account (zb0S216C)
helios wrote:
There's two possible interpretations for what you said, but in both cases you're wrong. Yes, it does.

In the code above, main( ) doesn't return a value, even though it should. I'm not thick, I do know that main( ) returns 0 if a returning value isn't specified. So instead of being bone idle, provide a returning value.

Wazzak
Topic archived. No new replies allowed.