This is very simple & easy program to print the first 10 natural numbers by using the C programming language. You can print the first 10 natural numbers without using the conditional loop.
Print the first 10 natural numbers by using the while loop. C program to Print First 10 Natural Numbers
1 2 3 4 5 6 7 8 9 10 11 12 |
#include<stdio.h> int main() { int i = 1; while (i <= 10) { printf("%d", i); i++; } return (0); } |
Print the first 10 natural numbers by using the for a loop.
1 2 3 4 5 6 7 8 9 10 |
#include<stdio.h> int main() { int i = 1; for (i = 1; i <= 10; i++) { printf("%d", i); } return (0); } |
Output is:
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: first 10 natural numbers, first 10 natural numbers in c, first five natural numbers, first n natural numbers, sum of first n natural numbers formula