Pages

How to print 1 to 10 natural numbers through for loop

//How to print 1 to 10 natural numbers through for loop


#include<stdio.h>
#include<conio.h>

void main()
{
  int num1,i;
  clrscr();
  printf("Natural numbers upto 10:");
  num1=0;
  for(i=0;i<10;i++)
  {
   num1=num1+1;
   printf("\n%d",num1);
  }
  getch();
}

Output:

Natural numbers upto 10:
1
2
3
4
5
6
7
8
9
10

No comments:

Post a Comment