C++ while Loop
๐ C++ while Loop
while loop ka use tab hota hai jab humein nahi pata ho ki loop kitni baar chalega, bas condition true rehni chahiye.
๐น 1. Syntax
๐ Condition true rahegi tab tak loop chalta rahega.
๐น 2. Basic Example
Output:
๐น 3. Print Even Numbers
๐น 4. User Controlled Loop
๐น 5. Infinite while Loop โ
โ ๏ธ Condition kabhi false nahi hoti.
โ Controlled version:
๐น 6. while vs do-while
| while | do-while |
|---|---|
| Pehle condition check | Pehle execute |
| 0 ya more times | At least once |
๐น 7. Common Mistakes
โ Correct:
๐ Summary
-
whileloop condition-based hota hai -
Entry-controlled loop
-
Infinite loop se bachein
-
Best jab iterations unknown ho
