Qhimm.com Forums
Miscellaneous Forums => Scripting and Reverse Engineering => Topic started by: Zophixan on 2002-10-31 13:17:08
-
There is a parse error on line 35
#include <iostream.h>
int main()
{
int age;
cout<<"plz input your age: ";
cin>>age;
if (age<14)
{
cout<<"you are younger than me!";
}
else if(age==14)
{
cout<<"you are the same age as me";
}
else if(age>14)
{
cout<<"you are older than me!"
}
else
{
cout<<"I have no idea how old you are";
}
return 0;
}
-
cout<<"you are older than me!"
should be
cout<<"you are older than me!";
you forgot the ; on it.
It would probably be a good idea to make a myage variable and set that to your age. It'll save some time when your age changes.
These changes should make your whole code look something like this:
#include <iostream.h>
int main()
{
int age;
int myage;
myage==14;
cout<<"plz input your age: ";
cin>>age;
if (age<myage){
cout<<"you are younger than me!";
}else if(age==myage){
cout<<"you are the same age as me";
}else if(age>myage){
cout<<"you are older than me!";
}else{
cout<<"I have no idea how old you are";
}
return 0;
}
-
Thanks but I solved it already!
-
And few lines could be thrown away, because IMHO last case will be never executed. And assignment operator is '='; '==' is comparison.
#include <iostream.h>
void main()
{
int age;
int myage = 14;
cout<<"plz input your age: ";
cin>>age;
if (age<myage)
cout<<"you are younger than me!";
else if(age==myage)
cout<<"you are the same age as me";
else
cout<<"you are older than me!";
}