Comment on the below while statement
while (0 == 0) { } A) It has syntax error as there are no statements within braces {}
B) It will run forever
C) It compares 0 with 0 and since they are equal it will exit the loop immediately
D) It has syntax error as the same number is being compared with itself
Answers
Answered by
0
Answer:
C)It compares 0 with 0 and since they are equal it will exit the loop immidiately. Hope it may help you
Answered by
1
Option B) It will run forever
while (0 == 0) { } A) It has syntax error as there are no statements within braces {}
- A do loop with a conditional expression set to a constant value of 0 can be visible (0).
- This establishes a loop that will run just once. A multi-line macro can now be used anyplace a single statement can be used thanks to a coding idiom.
- It is an endless loop that won't stop until a break statement is expressly supplied. Interestingly, any integer that is non-zero will have a similar impact to while as opposed to just while(1) (1). Because of this, while(1), while(2), or while(-255) will all result in an unending loop.
whereas while(true) ==while(1) ==> while(any value resembling true);
while(false)==while(0);
#SPJ3
Similar questions