HELP!!! (code problem) Qwik ?? about #s from the keyboard and add them together!!

ok so i used the code listed below, BUT when i build the solution an error shows and says that "cout, cin, and endl" are "undefined"
I am using Microsoft Visual studio 2010.... can anybody help me to figure out why it keeps saying this? please i would greatly appreciate it.

#include <iostream>

int main()
{
double sum = 0.0;

for (int i = 0; i < 10; i++) {
double input;

cout << "num" << i << "#: ";
cin >> input;
sum += input;
}

cout << "Sum equals " << sum << endl;
return 0;

} // end program
Last edited on
they live in the std namespace.

You must either use them like this:

1
2
3
std::cout
std::cin
std::endl


or put a using namespace std; at the start of your code, or put

1
2
3
using std::cout;
using std::cin;
using std::endl;


at the start of your code.

http://www.cplusplus.com/doc/tutorial/namespaces/
They are inside the std namespace.
You can fix that by adding using namespace std after the line #include<iostream>
or prepending std:: to cin cout and endl.

Please use [code][/code] tags
Topic archived. No new replies allowed.