+ 4
What is infinite loops
can u explain with a real life example
13 Answers
+ 15
while (true) {
//your are breathing until you die, this can be called infinite loop....^_^
}
+ 13
in a very simple word a infinite loop is endless loop .
& a real life example of infinite loop is:
a daily calendar.
+ 11
@valentin.. it will break when you die đđ
+ 5
a loop which never get a condition for terminating itself.
eg-
for(;;)
{
}
while(true)
{
}
+ 5
infinite loop with use.....
int choice;
while(1)//infinite loop
{
cout<<"Press 1 to push";
cout<<"press 2 to pop";
cout<<"Press 3 to exit";
cout<<"Enter your choice";
cin>>choice;
switch(choice){
case 1://do push code here.....
break;
case 2://do pop code here.....
break;
case 3:exit();//infinite loop ends if this case occures
default:cout<<"Wrong Input";
break;
}
}
+ 3
@sona, a daily calender......I like it :)
+ 2
Maybe you want your program to keep resetting after each use for example:
I made a calculator, I want to user to input whatever and when they get the result, It will loop the whole program or the input getting methods again.
+ 2
it has no end
+ 2
it has no end
+ 2
for(int i=0;;i++)
+ 1
Guysss, I found a real life example(inside TV) on infinite loop. It Spongebob's Best Day Ever Song. Hehehe... :)
+ 1
an endless loop is known as infinite loop
0
this is a infinite loop. 0x2=0 it will keep doing it until it gets to 10 which won't happen since 0 times anything will always be 0 lol
public class Program {
public static void main(String[] args) {
for(int x=0; x<=10; x=x*2) {
System.out.println(x);
}
}
}