# #Clanguage

1 vote
146 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??

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.

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
0
What about garbase values??
0
garbage values may be  coming from inside the loop due to may reasons

1 vote