Mega Code Archive

 
Categories / C / Code Snippets
 

If statement inside for loop

#include <stdio.h> #include <conio.h> int main(void) { int j; char ch; /* display all numbers which are multiples of 7 */ for(j = 5; j < 800; j++) { if(!( j % 7 )) { printf("%d, more number? (Y/N)", j); ch = getche(); if(ch == 'N') break; /* stop the loop */ printf("\n"); } } return 0; }