We often come across situations where we want to jump out of a loop immediately, without to get back to the conditional test. The keyword break allows us to do this.
#include <stdio.h>
#include <conio.h>
void main() {
int i=1;
clrscr();
for( ; ; ) {
printf("%d", i);
if(i>=10) {
break;
}
i++;
}
getch();
}
#include <conio.h>
void main() {
int i=1;
clrscr();
for( ; ; ) {
printf("%d", i);
if(i>=10) {
break;
}
i++;
}
getch();
}
Post a Comment