Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conversion of infinite for loop to finite for loop

Tags:

c

in C,how can we convert an infinite loop into finite loop without wrinting anything in syntax of for loop....

#include<stdio.h>
#include<conio.h>
int main()
{
    int a;
    a=1;
    a++;
    for( ; ; )
    {
       a<=10;
       printf("%d",a); 
    }
    getch();
}
like image 658
Sakshi Jain Avatar asked Dec 09 '25 02:12

Sakshi Jain


1 Answers

You could use break statement there.

This will exit the loop and start control beneath the loop body.

like image 194
alex Avatar answered Dec 10 '25 16:12

alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!