[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

programming errors

whats wrong with this code
#include<iostream>

void main()
{
int n;
cout << "Please enter number";
cin << n;
}
0
helloworldcc
Asked:
helloworldcc
1 Solution
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now