+ 1
Will this go to infinite loop?
#include<stdio.h> void main() { int a=0; while(a==0) { printf("hello"); } }
6 Answers
+ 3
loop repeats as long as loop condition( "a" being equal to 0) is met. Since "a" is initialized as 0, loop condition will be met and the loop is guaranteed to run at least once.
At the end of a loop, condition is checked again, to repeat the loop if the condition is true. Since "a" remains unchanged (it remains 0), condition will be true, and the loop will run again. This will repeat infinitely
+ 2
Data can you explain it, thank u
+ 2
athik rehman
there is a joke about programmer
A wife said to his husband
while you are out buy some milk
so he never came back
(because there is no end condition how much milk)
so is your loop it is always true and it will always run
and loop always run until the condition become false
hope you find it usefull
+ 2
athik rehman thanks
+ 1
yes, "a" is never changed
0
Amir Ahmad kya baat hyy iskeyliye waiting shukriya