If Then Else Nested: Largest Integer

Hello everyone! this is my first post on here. Currently I am working on a project for my introduction to computer science course and I have run into a few problems. The project is to create a program that allows the user to input three values and it outputs the largest of the three. I am to use nested If-Then-Else statements but I have run into a few problems. First off, I am not sure if my program is too complicated than what it is supposed to be. I will upload a picture of the code thus far. I also ran into a n error stating " expected primary expression before else" and "expected ';' before else". Not too sure how to fix these problems. Please, any help will be awesome. Thank you all.
// INPUT - User must enter the three integers.
cout << left;
cout << setw(8) << "Value 1: ";
cin >> value1;
cout << setw(8) << "Value 2: ";
cin >> value2;
cout << setw(8) << "Value 3: ";
cin >> value3;

// PROCESSING - Determine which value is the largest.

if (value1>value2)
{
if(value1>value3);
{
cout << "The largest value is the 1st value: " << value1 ;
cout << endl;
}
else
{
if(value3>value2)
{
cout << "The largest value is the 3rd value: " << value3;
cout << endl;
}
else
{
"The largest value is the 2nd value: " << value2;
cout << endl;
}
}

}
Last edited on
closed account (zvRX92yv)
http://www.cplusplus.com/articles/Ny86b7Xj/

Well, you got the title part right, but you didn't enclose your code in [code][/code] tags.

Read the tutorial on this website, it will help you to solve your problem.
Last edited on
At least remove the semicolon in the statement

if(value1>value3);
Topic archived. No new replies allowed.