Solved

programming errors

Posted on 2003-11-28
6
365 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…

749 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