C Program that Print First 10 Natural Numbers using For, While and Do-While Loop
Posted by Samath
Last Updated: January 02, 2017

Write a C Program that Print First 10 Natural Numbers using For, While and Do-While Loop.

A natural number is a number that occurs commonly and obviously in nature. As such, it is a whole, non-negative number. The set of natural numbers, denoted N, can be defined in either of two ways:

N = {0, 1, 2, 3, ...}

N = (1, 2, 3, 4, ...}

Using For Loop:

#include<stdio.h>
 
int main() {
   int i = 1;
 
   for (i = 1; i <= 10; i++) {
      printf("%d", i);
   }
   return (0);
}

Using While Loop:

#include<stdio.h>
 
int main() {
   int i = 1;
 
   while (i <= 10) {
      printf("%d", i);
      i++;
   }
 
   return (0);
}

Using Do-While Loop:

#include<stdio.h>
 
int main() {
   int i = 1;
 
   do {
      printf("%d", i);
      i++;
   } while (i <= 10);
 
   return (0);
}