Showing 1 to 100 with line break at each 10
Display number 1 to 100
There should be linke break after 10, 20, 30 .... etc
We will use math fmod() or % to check the reminder of division by 10
#include <stdio.h>
int main(void){
int i;
for(i=1;i<=100;i++){
printf("%d,",i);
if((i%10)==0){
printf("\n");
}
}
return 0;
}
More on for loop.
This article is written by plus2net.com team.
plus2net.com