C Program to print first 10 Natural Numbers
Using For Loop#include<stdio.h> #include<conio.h> void main() { int i=1; clrscr(); for(i=1;i<=10;i++) printf("%d",i); getch(); }
Using While Loop
#include<stdio.h> #include<conio.h> void main() { int i=1; clrscr(); while(i<=10) { printf("%d",i); i++; } getch(); }
Using Do-While Loop
#include<stdio.h> #include<conio.h> void main() { int i=1; clrscr(); do{ printf("%d",i); i++; }while(i<=10); getch(); }
No comments:
Post a Comment