programming errors

whats wrong with this code
#include<iostream>

void main()
{
int n;
cout << "Please enter number";
cin << n;
}
helloworldccAsked:
Who is Participating?
 
thegameskeeperCommented:
i think cin should be

cin >> n;
0
 
helloworldccAuthor Commented:
that doesnt make sense but, it seems to work, im still a beginner
0
 
ChillerCommented:
it Does make sense because the streams stream the other direction
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
jadoogarCommented:
your cin operator is wrongly used that is

cin >> n; i think
0
 
Eric-KCommented:
maybe it would make better sense if you worote it like this:
cout << "Please enter number";
n << cin;

or like this:
"Please enter number" >> cout;
cin >> n;

The arrows indicate the direction of the flow of data ...
in one case you want the data to flow from the constant string in your program, to the output device (cout)

In the other case, you want the data to flow from the input device (cin) to program variable.

-Eric
0
 
pv12206Commented:
the directive #include <iostream> is not the right header file. If you are writing code in standard C++, It should be #include<iostream.h> the .h you're missing here. Or code in ISO standard C++ ,     add the line " using namespace std; " right after the #include<iostream>.
And also you have the wrong shift operator for cin.

Phong
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.