391 views
1 votes
1 votes
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??

2 Answers

1 votes
1 votes

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 votes
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

Related questions

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