again please

HELP about if else

If(A>B)
{
printf("You win");
}
else if(A<B)
{
printf("You lose");
}
else if(A=B)
{
printf("Its a tie");
}

in some part of my program printf become rumble even condition is true it tells other statement..any help
you wrote If(A>B), it should be if(A>B) but I have a feeling that was only a typo.


printf or cout are good ways to tell if your program has satisfied a particular if condition. If you are triggering the printf, then your condition must be true.

Try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
printf("A is: %i and B is: %i\n", A,B)
if(A>B)
{
    printf("You win");
}
else if(A<B)
{
    printf("You lose");
}
else if(A=B)
{
    printf("Its a tie");
}


If you are still not getting what you've expected, then you've messed up your control structure some how.
closed account (DSLq5Di1)
You are assigning B to A in your else if statement, == tests for equality.
Topic archived. No new replies allowed.