What is While Loop In C++

The while statement is used when the program needs to perform repetitive tasks. The general form of a while statement is:

while (condition)

The program will repeatedly execute the statement inside the while until the condition
becomes false (0).(If the condition is initially false, the statement will not be executed.)

In our while loop we compute the value of current_number and print it Next we need to
advance one term.This completes the body of the loop. The first two terms of the Fibonacci sequence are 1 and 1. We initialize our first two terms to these values.

A while loop executes statements repeatedly until the given condition evaluates to false. This control statement is used when it is not known, in advance, how many times a block of code is to be executed.

while loop may be used where we don’t know how many times loop must be run.Syntax of while loop in c++.


Print Codeverb.com message for 5 times by using while loop

using namespace std;
int main(){
int i;
cout<<“Codeverb.com %dn”,i);
return 0;

Codeverb.com 1
Codeverb.com 2
Codeverb.com 3
Codeverb.com 4
Codeverb.com 5

If you like this post, don’t forget to share 🙂

This article is written by our awesome writer
Comments to: While Loop In C++

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Join our Newsletter

Get our monthly recap with the latest news, articles and resources.

By subscribing you agree to our Privacy Policy.

Latest Articles

Explore Tutorials By Categories


Codeverb is simply an all in one interactive learning portal, we regularly add new topics and keep improving the existing ones, if you have any suggestions, questions, bugs issue or any other queries you can simply reach us via the contact page


Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
    Strength indicator
    Log In | Lost Password