The Gateway to Computer Science Excellence
+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??
in Programming by Boss (25.6k points) | 119 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.

by Veteran (63k points)
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
by Boss (49.3k points)
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
asked Aug 16, 2016 in Programming by papesh Boss (25.6k points) | 184 views
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,258 answers
198,086 comments
104,735 users