Making complicated decisions
sokin
Posts: 32
in Propeller 1
Does anyone know how I would modify a or b to make it only print one message? I am working on the "make complicated decisions" part on parallax's website.
int main() // main function
{
int a = 17; // Initialize a variable to 25
int b = 17; // Initialize b variable to 17
print("a = %d, b = %d\n", a, b); // Print all
if((a > b) || (a == 100)) // If a > b OR A == 100
{
print("a might be larger than b, \n"); //Then print this message
print("OR a might be 100, \n"); //Then print this message
print("OR mabey both!\n"); //Then print this message
}
}
Thanks in advance
int main() // main function
{
int a = 17; // Initialize a variable to 25
int b = 17; // Initialize b variable to 17
print("a = %d, b = %d\n", a, b); // Print all
if((a > b) || (a == 100)) // If a > b OR A == 100
{
print("a might be larger than b, \n"); //Then print this message
print("OR a might be 100, \n"); //Then print this message
print("OR mabey both!\n"); //Then print this message
}
}
Thanks in advance
Comments
If you want the messages dependent of the values, you need separate IF tests:
Andy
I have it edited
Could also be done with a switch/case method.