WTF WHY IS THIS NOT WORKING

INSTRUCTIONS:
Write a complete program that
declares an integer variable,
reads a value from the keyboard into that variable, and
writes to standard output the square of the variable's value.

Besides the number, nothing else should be written to standard output.


My answer :

#include <iostream>
using namespace std;
int main()
{
int name;
int result;
cin >> name >> endl;
result = (name*name);
cout << result << endl;
return 0;
}


The error I keep getting: CTest.cpp: In function 'int main()':
CTest.cpp:6: error: 'name' was not declared in this scope

Calm down sir.

cin >> name >> endl;

endl is for cout, not use for cin.

cin >> name;
Cool down man
why don't try to eliminate
>> endl;
,trust me, you would be illuminated.
you know what,Patience is the key of programming.
Take a chill pill dude.
endl means "put a newline", it's not something you can read a value into.
Topic archived. No new replies allowed.