Write the difference between a finite and infinite loop.
Answers
A function is set of instruction that perform some specific operation .
There are two type of loops one is finite and other is infinite.
A finite loop is one that end after finite runs and
an infinite loop is one that never ends itself.
Difference between finite and infinite loop is given below-
Finite loop is defined as the coding sequence which executes for finite or countable number of times.
Example of finite loop code is-
int main(){
for(int I=4; I<= 14, I++)
{
}
return 0;
}
Infinite loop is defined as the loop which goes on, and never ends. This may occur either due to wrong value or where infinite condition is given.
Example of infinite loop code is-
int main(){
for(int i=1; i>= 1; I++)
{
} return 0;
}
This loop is infinite because on adding the value to 1, it will always remain greater than 1, and hence it will go on for infinite times.