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

print 1 to 4 using while loop in C Programming

👁 1,723 Views
💻 Practical Program
📘 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;
}
                        

🖥 Program 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.
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.