Home / Programs / print 1 to 4 using while loop in C Programming
Programming Example

print 1 to 4 using while loop in C Programming

👁 1,722 Views
💻 Practical Program
📘 Step by Step Learning
This program will print 1 to 4 using while loop

Program Code

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

Output

1 2 3 4

Explanation

A while loop in C programming repeatedly executes a target statement as long as a given condition is true.

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.