| ugly0hugly (6) | |
|
Hello im a newbie and I dont understand c++ that much but im still learning. I can't seem to find what my error is for this basic program...Mind helping me and showing me the way? #include <iostream> using namespace std; int a; int b; int main () { cout << "hello sajjad!"; cout <<"put in your age..."; cin>> a; } //Person was born on feb. 29(leap year) if (a==0<) { cout<< "Sajjad is"; b=a/4; cout<<b cout<<"YEARS OLD!!!"; cout<<"HAHAHA!!!"; return 0; } else (a!=0<) { cout>> "UGLY!HUGLY!FUGLY!"; return0; } | |
|
|
|
| Longazan (22) | |||
First thing first, next time use the code tag (the <> symbol on the right under Format) to make the code easier to see. The if and else statement is not in any function, I think you main to put them in the main function i.e like this
Your main function should also return something, usually return 0; and I do not think your comparisons are valid. | |||
|
|
|||
| SamuelAdams (320) | |
what he said, andcout<<b;
| |
|
Last edited on
|
|
| dumb0t (21) | |
| use an IDE | |
|
|
|
| ugly0hugly (6) | |
|
Thank you ill remember that but now it shows this: sajjads age sc.cpp(13): error C2447: '{' : missing function header (old-style formal list?) Any Idea to what that means?And also I don't know what an IDE is yet...Im only on p.35 of 144 on the guide for c++... | |
|
Last edited on
|
|
| Longazan (22) | |
| IDE stand for Integrated Development Environment; it is used to help coding and compiling programs easier. For the error, if you post the code again, this time use the <> tag, it would help us see what you did wrong. | |
|
|
|
| tvrameshmc (54) | |||
There is a closing } after cin>> a;. This means main function ends until there so compiler giving error.Place a closing bracket at the end.
| |||
|
Last edited on
|
|||
| Fransje (238) | |
This: if (a==0<) is wrong, you need to skip the '<' : if (a==0) (also in line 23)And this: cout>> "UGLY!HUGLY!FUGLY!"; should be: cout<< "UGLY!HUGLY!FUGLY!";
| |
|
Last edited on
|
|