#include<iostream>
#include<cmath>
usingnamespace std;
int main() {
cout << "Enter three numbers: " << endl;
char cond1,cond2,cond3;
int num1, num2, num3;
cin >> num1 >> num2 >> num3;
if (num1>num2);{
cond1 = 't';}
else{
cond1 = 'f'
}
if (num1>num3){
cond2 = 't'}
else{
cond2 = 'f'}
if (num2>num3){
cond3 = 't'}
else{
cond3 = 'f'}
if (cond1 == 't' && cond2 == 't'){
cout << num1 << " is the maximum" << endl;
elseif (cond1 == 't' && cond2 == 'f'){
cout << num3 << " is the maximum" << endl;}
elseif (cond1 == 'f' && cond3 == 't'){
cout << num2 << " is the maximum" << endl;}
}
if (cond1 == 'f' && cond2 == 'f') {
cout << num1 << " is the minimum" << endl;
}
elseif (cond1 == 't' && cond3 == 'f'){
cout << num2 << " is the minimum" << endl;}
elseif (cond2 == 't' && cond3 == 't');{
cout << num3 << " is the minimum" << endl;}
}
return 0;
Please excuse the sloppy formatting.
Here are the errors I am receiving when I try to run the code:
1 2 3 4 5 6 7 8 9
Lab3P2.cpp: In function 'int main()':
Lab3P2.cpp:15: error: expected `}' before 'else'
Lab3P2.cpp: At global scope:
Lab3P2.cpp:15: error: expected unqualified-id before 'else'
Lab3P2.cpp:18: error: expected unqualified-id before 'if'
Lab3P2.cpp:20: error: expected unqualified-id before 'else'
Lab3P2.cpp:22: error: expected unqualified-id before 'if'
Lab3P2.cpp:24: error: expected unqualified-id before 'else'
Lab3P2.cpp:28: error: expected unqualified-id before 'if'
I have no idea what they mean by "expected unqualified-id before", and every time I add the } before "else" in line 15, I just get more errors.
Thanks for the help so far. I did what you guys said, and now I've gotten these errors:
1 2 3 4 5 6 7 8
Lab3P2.cpp: In function 'int main()':
Lab3P2.cpp:29: error: expected `}' before 'else'
Lab3P2.cpp: At global scope:
Lab3P2.cpp:35: error: expected unqualified-id before 'if'
Lab3P2.cpp:38: error: expected unqualified-id before 'else'
Lab3P2.cpp:40: error: expected unqualified-id before 'else'
Lab3P2.cpp:40: error: expected unqualified-id before '{' token
Lab3P2.cpp:42: error: expected declaration before '}' token
So I get a few more of the expected unqualified-id errors, but in different lines now, and I'm still not entirely sure what this is supposed to mean.