+1 vote
119 views
Suppose in my c program having infinite loop and it is printing garbase values ... Because of some logical errors... So till what time it will run and why ???

Will it give error if yes than why??
| 119 views

+1 vote

initialy int i= 16; while(i>0) {     i++;     print("%d", i); }

you are done logical error i++ instead of i--.
since int has some limit to store aftr when limit exhaust then some vaue wil be trancated and u get garbage.

by Veteran (63k points)
0

while(true)  {       print("Hello");  }

0
garbage is not given here . hello is printed.
since it is infinite loop and assuming  there is no break in it  then it will run for indefinite time there should be no error as it is not a syntx error and it is perfectly valid to have an infinite loop
by Boss (49.3k points)
0