### Can someone solve this for me?

Can someone try and solve this for me? I can't find out whats wrong. Can someone try this them selves and find out what I did wrong? PLz

 ``123456789101112131415161718192021222324252627282930313233`` ``````#include 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<
closed account (LN7oGNh0)
Put your if/else statements in between the `int main()` brackets. OH! And dont forget `return 0;`!

 ``12345678910111213141516171819202122`` ``````int main() { cout << "hello sajjad!"; cout <<"put in your age..."; cin>> a; if (a==0) { cout<< "Sajjad is"; b=a/4; cout<

Sorry I couldnt get all of it. Ive got work to do.
What does that mean I don't get it. Can you show an example?
Your braces for `int main()` must be around the code, like illustrated by Hazique35.
I tried what he did but I still get errors. I'm using visual c++ 2010 by the way.

 ``123456789101112131415161718192021222324252627282930313233`` ``````#include 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<
Last edited on
You could simplify it like this

 ``12345678910111213`` ``````int main() { cout << "hello sajjad, "; cout <<"put in your age...\n"; cin>> a; if (a==0) { // why would you accept 0 as an age? cout<< "Sajjad is "; // notice a space is added, makes it look a bit better b=a/4; // this always assigns b to 0 cout<
I don't know why when ever I do it it never seems to work. there is always an error.

fatal error LNK1169: one or more multiply defined symbols found
 ``123456789101112131415161718`` ``````#include using namespace std; int a; int b; int main() { cout << "hello sajjad, "; cout <<"put in your age...\n"; cin>> a; if (a==0) { // why would you accept 0 as an age? I was thinking of replacing the variable with something that goes from 0 to infinite or somthing cout<< "Sajjad is "; // notice a space is added, makes it look a bit better b=a/4; // this always assigns b to 0 cout<
Last edited on
closed account (D80DSL3A)
There should be no code below what appears in your post above. Is there still stray code (lines 14-33 in your opening post) below main?
Your program is correct.

I think you are using more than one source files in your project and `main()` is already written in another file.

Maintain only one `main()` function for one project or you can start new project and try it there.
Last edited on
closed account (LN7oGNh0)
I agree with tvrameshmc. I'm pretty sure I did that when I first started.
Topic archived. No new replies allowed.