-5

so Sorry admin If the Code is posted in wrong way, I can't understand how to post the code. Its a Code in Codeblocks,

So yup my problem is I have to Take three integers from User and The Code will see which one is the largest and will display it on screen. So in my Code everything is fine but when ever i try to run it is is giving error on if line saying error expected '{' before token and some other error like that I even put {} these but still error . So Anyone help me out :)

int Number1 , Number2 , Number3;
cout<<"Enter First Number"<<endl;
cin>>Number1;
cout<<"Enter Second Number"<<endl;
cin>>Number2;
cout<<"Enter Third Number"<<endl;
cin>>Number3;

if ("Number1 > Number2") && ("Number1 > Number3")
    cout<<"Number1 is the Largest Number"<<endl;
if {(Number2>Number1) && (Number2>Number3)}:
    cout<<"Number2 is the largest Number"<<endl;
else
    cout<<"Number3 is the Largest Number"<<endl;
return 0;
Post Self
  • 1,471
  • 2
  • 14
  • 34
AHMED ALI
  • 27
  • 5
  • 4
    I highly recommend that you get a [good book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list), because you seem to guess the syntax. – Rakete1111 Sep 23 '17 at 14:25
  • @Rakete1111 Didn't Understand Good book??? what?? – AHMED ALI Sep 23 '17 at 14:43
  • @Rakete1111 Yup I can Guess Syntax error But New in Code blocks , And Yup i am also Learning Python So python is more easy then C++ But my Subject is C++ :) So Yup new some help. – AHMED ALI Sep 23 '17 at 14:44
  • I'm just saying that you'll need to get a book to learn C++, there are very few good C++ online tutorials. The link is just a link to list of books that have proved to be good books for learning C++. – Rakete1111 Sep 23 '17 at 14:46
  • Colons are not used like this in C++. Also, your syntax is not even consistent – Post Self Sep 23 '17 at 14:47
  • @Rakete1111 will get A book.. – AHMED ALI Sep 23 '17 at 14:48
  • But for Now i need help which thing is wrong in my coding. – AHMED ALI Sep 23 '17 at 14:49
  • i am tested that if line with ; and without ; and with even {} "" but still nothing – AHMED ALI Sep 23 '17 at 14:49

1 Answers1

0

If statements in C++ are written like this:

if (Number1 > Number2 && Number1 > Number3)
    cout << "Number1 is the Largest Number" << endl;
if (Number2 > Number1 && Number2 > Number3)
    cout << "Number2 is the largest Number" << endl;
else
    cout << "Number3 is the Largest Number" << endl;

No colons, no curly braces in the condition, no quotation marks, and only one pair of parentheses.

Post Self
  • 1,471
  • 2
  • 14
  • 34