Solved

programming errors

Posted on 2003-11-28
6
364 Views
Last Modified: 2010-04-17
whats wrong with this code
#include<iostream>

void main()
{
int n;
cout << "Please enter number";
cin << n;
}
0
Comment
Question by:helloworldcc
6 Comments
 

Accepted Solution

by:
thegameskeeper earned 125 total points
ID: 9838514
i think cin should be

cin >> n;
0
 

Author Comment

by:helloworldcc
ID: 9838530
that doesnt make sense but, it seems to work, im still a beginner
0
 

Expert Comment

by:Chiller
ID: 9840817
it Does make sense because the streams stream the other direction
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Expert Comment

by:jadoogar
ID: 9844698
your cin operator is wrongly used that is

cin >> n; i think
0
 

Expert Comment

by:Eric-K
ID: 9852298
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
 

Expert Comment

by:pv12206
ID: 9856099
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question