?
Solved

programming errors

Posted on 2003-11-28
6
Medium Priority
?
368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Accepted Solution

by:
thegameskeeper earned 375 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
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.

 

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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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.
Make the most of your online learning experience.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes

649 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