I am a beginner in C programming. Today, my teacher (who is not very good at teaching) assigned us with some homework that I attempted/tried to attempt.
1) The first problem wants me to write a C statement that will set "a" (a variable) to 1 if at least two of the three integer variables x, y, z are true (i.e. if any two or all three are true).
-I know this involves the use of an if statement, but I am not sure how to go about it.
Here is what I formulated, although I know it is not right:
if(x == 1 && y == 1) a = 1; if(y == 1 && z == 1) a = 1; if(x == 1 && z == 1) a = 1; if(x == 1 && y == 1 && z == 1) a = 1;
I want them to equal 1 because I set 1 to equal "true" and any number other than 1 to equal "not true". Am I on the right track or is this totally off?