Write a program in C to print all natural numbers up to given number.
#include<stdio.h> #include<conio.h> void main() { int i,n; clrscr(); printf("Enter anumber:-"); scanf("%d",&n); i=1; while(i<=n) { if(i%10==0) printf("%4d\n",i); else printf("%4d",i); i++; } getch(); }
Output:-
Related programs:
- Write a program in C to find sum of all natural numbers up to given number.
- Write a program in C to print all even and odd numbers up to given number.
- Write a program in C to count all even and odd numbers up to given number.
- Write a program in C to find sum of all even and odd numbers up to given number.
0 Comments