adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Write a program in C to print all natural numbers up to given number.

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:
  1. Write a program in C to find sum of all natural numbers up to given number.
  2. Write a program in C to print all even and odd numbers up to given number.
  3. Write a program in C to count all even and odd numbers up to given number.
  4. Write a program in C to find sum of all even and odd numbers up to given number.

Post a Comment

0 Comments