while Loop in C++

Get acquainted with the while loop and its basic syntax.

Introduction

Suppose you have $20, and the price of an ice-cream is $5. You want to keep buying the ice-cream until you have no money left. This task is repetitive, and you don’t know in advance how many ice-creams you can buy.

In the era of programming, we can use the while loop to implement repetitive tasks.


The while loop keeps executing a particular code block until the given condition is true. It does not know in advance how many times the loop body
...