Answers for "exit loop c"

C
6

how to break a loop in c

// The code will print your number 10 times if x <= 100

int x = 120;
for (int i = 0; i < 10; i++)
{
	if (x > 100)
    
		// Note: if multiple for loops: breaks the superficial one
    	break;
    else
	
        printf("%i\n", x);
}
Posted by: Guest on June-22-2020
0

exit loop c

#include <stdio.h>
 
int main () {

   for (int i = 1; i <= 100; i++)
	{
		if (i == 5)
		{
			//use break, same as c#
            break;
		}
	}
 
   return 0;
}
Posted by: Guest on April-22-2021

Code answers related to "C"

Browse Popular Code Answers by Language