Oh, I see.

So the correct syntax would be:
#include <iostream>
using namespace std;
int main()
{
int a, b;
a = 4 * 6; // (Note use of comments and of semicolon) a is 24
b = a + 5; // b equals the original value of a with five added to it
cout<<"Please enter letter a or b: ";
cin>> a;
cin>> b;
cin.get();
if (a<b) {
cout<<"You entered 'a' which equals: "<< a <<endl;
}
else {
cout<<"You entered 'b' which equals: "<< b <<endl;
}
}
?
Well, that gave the correct value for a, but not for b. :?? b is saying it equals 24 instead of 29.
Addendum:
Ok...so I'm a little lost on how the "if" statement is supposed to make it display the right thing. :wtf: I understand that if the "if" statement is true, then the code that is enclosed in the braces under it is executed, but if it is false, it executes the code under the "else" statement. So how does this help me, since if I give it a correct statement, i.e.
then it'll run the code following it, which is
cout<<"You entered 'a' which equals: "<< a <<endl;
}
but if it is false, it'll run the code under the "else" statement, like this
else {
cout<<"You entered 'b' which equals: "<< b <<endl;
}
so obviously since the statement is *true* it'll say "You entered 'a' which equals: 24" regardless of which letter is actually given (whether a or b).
And if, on the other hand, I give a statement that is *false* like this
if (a > b) {
cout<<"You entered 'a' which equals: "<< a <<endl;
}
else {
cout<<"You entered 'b' which equals: "<< b <<endl;
it'll of course return the value of 29 (which is the value that the 'b' variable was given), regardless of which letter is given in the input because the "if" statement is false, and so the program skips it and reads from the "else" statement instead. So how does this help me at all? :| I would get the same result no matter what type of operators are given in the condition of the "if" statement.
FYI, I'm trying to find a way to get the program to display the correct output depending on which variable is given.
Jake
Addendum:
Man...I am so close!
Here is what I thought would work, but unfortunately I'm having the same problem as before, i.e. with the same thing being given in the output regardless of which variable is typed in:
#include <iostream>
using namespace std;
int main()
{
int a;
int b;
a = 4 * 6; // (Note use of comments and of semicolon) a is 24
b = a + 5; // b equals the original value of a with five added to it
cout<<"Please enter letter a or b: ";
cin>> a;
cin>> b;
cin.get();
if (a > b) {
cout<<"You entered 'a' which equals: "<< a <<endl;
}
else if (a=24) {
cout<<"You entered 'a' which equals: "<<a <<endl;
}
else if (b=29) {
cout<<"You entered 'b' which equals: "<< b <<endl;
}
}
As you can see, I made the "if" statement false, so it would read from the "else if" statements (which are true), which you can supposedly have multiple of. But I'm having the same problem as before...

It wont say the correct thing when the 'b' variable is given...it still says "You entered 'a' which equals 24".