If-else question

reddensoft

Banned-Spam
Joined
Oct 7, 2022
Messages
84
Reaction score
9
If ((a > b) && (a <= c))
a = a + 1;
else
c = c+1;

What is the result after execution of the following code if a is 10, b is 5, and c is 10?
 
What is this ? You are having a programming chat :D :D :D
 
If ((a > b) && (a <= c))
a = a + 1;
else
c = c+1;

What is the result after execution of the following code if a is 10, b is 5, and c is 10?
"a = a + 1" as a can be equal to c

You're posting the questions of your homework or some kind of test!?
 
a is 10, b is 5, and c is 10

((a > b) && (a <= c))

A is indeed more than B. And A is less or equal to C.

Since it satisfied both conditions, the end result will be: a=11
 
  • Like
Reactions: MV3
"a = a + 1" as a can be equal to c

You're posting the questions of your homework or some kind of test!?
I think it's more homework related. This guy needs to solve this to pass his high school exams...
 
You could also just execute it and see what the result is lol.
 
The code block will execute the if-condition because both conditions are true (a > b) and (a <= c). Therefore, a will be incremented by 1 and its value will be 11. The value of c will remain unchanged at 10. Hence, the result after execution of the following code if a is 10, b is 5, and c is 10 is a = 11 and c = 10.
 
The code block will execute the if-condition because both conditions are true (a > b) and (a <= c). Therefore, a will be incremented by 1 and its value will be 11. The value of c will remain unchanged at 10. Hence, the result after execution of the following code if a is 10, b is 5, and c is 10 is a = 11 and c = 10.
Fck, you´re so smart you even enjoyed trying to solve it.
 
Back
Top