Print number using while loop in C Programming

  • Tech Area
  • May 9, 2024



In this tutorial, We will see how to print numbers using while loop in C programming language.

Program to print numbers

#include<stdio.h>
#include<conio.h>
void main()
{
int a=1;
clrscr();
while(a<=5)
{
printf("%d\n", a);
a++;
}
getch();
}

Output

1
2
3
4
5

In this program, declare variable a=1 and then check condition while(a<=5).

int a=1;
while(a<=5)
{
printf("%d\n", a);
a++;
}

The printf() function is used to display the numbers.


Subscribe us via Email

Join 10,000+ subscriber

Subscribe on YouTube