Use break in for loop to exit
#include <stdio.h> int main(void) { int i; for(i = 1; i < 100; i++) { printf("%d ", i); if(i == 10) break; /* exit the for loop */ } return 0; }