If statement inside for loop
#include <stdio.h>
#include <conio.h>
int main(void)
{
int i;
char ch;
/* display all numbers which are multiples of 6 */
for(i = 5; i < 10000; i++) {
if(!( i % 6 )) {
printf("%d, more number? (Y/N)", i);
ch = getche();
if(ch == 'N')
break; /* stop the loop */
printf("\n");
}
}
return 0;
}
Related examples in the same category