C Program to Print First 10 Natural Numbers

Write a C program to print first 10 natural numbers using for loop.

#include <stdio.h>

int main()
{
	printf("The First 10 Natural Numbers are\n");
	
	for (int i = 1; i <= 10; i++)
	{
		printf("%d\n", i);
	}
}
C Program to Print First 10 Natural Numbers

This C program displays the first 10 natural numbers using a while loop.

#include <stdio.h>

int main()
{
	printf("The First 10 Natural Numbers are\n");

	int i = 1;
	while (i <= 10)
	{
		printf("%d\n", i);
		i++;
	}
}
The First 10 Natural Numbers are
1
2
3
4
5
6
7
8
9
10

This C example uses the do while loop to print the first 10 natural numbers.

#include <stdio.h>

int main()
{

	printf("The First 10 Natural Numbers are\n");
	int i = 1;
	do
	{
		printf("%d\n", i);

	} while (++i <= 10);
}
The First 10 Natural Numbers are
1
2
3
4
5
6
7
8
9
10