Dec 26, 2009 at 7:14pm UTC
I need help with the code.
#include <iostream>
using namespace std;
int main()
{
char letter = 's';
int number = 1000000;
float number2 = 6.9;
double number3 = 1.73;
bool ? = true;
cout << "The letter is " << letter << endl;
cout << "number is " << number << endl;
cout << "number 2 is " << number2 << endl;
cout << "number 3 is " << number3 << endl;
cout << "the source is " << ? << endl;
return 0;
}
I compiled it and tried to run it and it doesnt seem to work. Please Help me .
P.S I am a NooB
Dec 26, 2009 at 7:19pm UTC
? is not a valid variable name. this code should not even compile.
Dec 26, 2009 at 7:19pm UTC
Oh and can someone give me a brief description on how to write variables please?
Dec 26, 2009 at 7:23pm UTC
What should i replace ? with?
Dec 26, 2009 at 7:33pm UTC
You have a bunch of correct variable names there (letter, number, number2, number3). Can you figure it out?
Dec 26, 2009 at 7:35pm UTC
sorry, i am trying to learn from a book i got but its not very good at explaining things. :(
Dec 26, 2009 at 7:42pm UTC
Nope i dont understand whats wrong.
Dec 26, 2009 at 8:20pm UTC
A variable can't contain a '?'. It must start with a letter or an underscore, after the first letter any letter, number and underscore can come.
examples:
x1
_x2
variable
variable2
Last edited on Dec 26, 2009 at 8:20pm UTC
Dec 26, 2009 at 8:29pm UTC
Okay thanks for all of your help i change it and it works now
thank you all.