search
Log In
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??
in Programming 146 views

2 Answers

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"); 
}
 

What about this??

0
garbage is not given here . hello is printed.
0 votes
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

Related questions

1 vote
1 answer
1
238 views
What is output of the program?? And why??
asked Aug 16, 2016 in Programming papesh 238 views
6 votes
3 answers
2
243 views
int i; i=5; i=i++; printf("%d",i); What is output of this program?? Is it undefined behavior ?? Why??
asked Aug 15, 2016 in Programming papesh 243 views
...