Using for loop:
#include<stdio.h> int main( ) { int i; for(i=1; i<=10; i++) { printf("%d\t",i); } return 0; }
Output:
1 2 3 4 5 6 7 8 9 10
Using while loop:
#include<stdio.h> int main( ) { int i=1; while(i<=10) { printf("%d\t", i); i++; } }
Output:
1 2 3 4 5 6 7 8 9 10
Using do…while loop:
#include<stdio.h> int main( ) { int i=1; do{ printf("%d\t", i); i++; }while(i<=10); }
Output:
1 2 3 4 5 6 7 8 9 10