While Loop in c++

It is often the case in programming that you want to do something a fixed number of times. Perhaps you want to calculate gross salaries of ten different persons, or you want to convert temperatures from centigrade to fahrenheit for 15 different cities.

initialise loop counter ; 

while ( test loop counter using a condition ) 

{

do this ; 

and this ; 

increment loop counter ; 


example:-

int i=0

while ( i<5) 

{

cout<<"Hello\n";

i++;

Here the out put of this example will be 

Hello

Hello

Hello

Hello

Hello

Nesting of While Loop

int i=0,j;

while ( i<3) 

{

j=0

while(j<2)

{

cout<<"Hello\t";

j++;

}

i++;

cout<<"\n";

Here the out put of this example will be 

Hello          Hello

Hello          Hello

Hello          Hello

You may also like

What is PHP?

PHP stands for PHP: Hypertext pre-processor, with that PHP standi...

What is ASP.NET?

ASP.NET, the next version of ASP, is a programming framework used...

What is Data Structure?

A data structure is a group of data elements grouped together und...

What is C#?

C# removes some of the complexities and pitfalls of languages suc...

What is Math?

Math is no Definition it has only Calculation.Closure Property of...

What is Oracle?

Based in Redwood, California, Oracle Corporation is the largest s...

Function in java

A function in Java language is a block of code that performs a sp...

Do-While Loop in java

The do-while loop looks like this:do{ this ; and this ; and this ...