answersLogoWhite

0

There are three forms of loop commonly used in C/C++, the for loop, the while loop

and the do-while loop.

The for loop is most commonly used whenever an action is going to be performed a set amount of times. For example, to sum every element in an array:

for(i = 0; i < arraySize; i++)

{

sum = sum + array[i];

}

The while loop and do-while loop are commonly used to loop until a condition is met. The difference between the two is that the do-while loop goes through one iteration before checking its condition, while the while loop checks its condition before any execution of the loop.

Example do-while loop:

do

{

randomNumber = rand() % 10;

}while(randomNumber != 6);

Example while loop:

cout > number;

while(number < 0)

{

cout > number;

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Types of fingerprint patterns?

Whirl, Loops, Double Loops, Arc.


Types of fingerprints?

There is three types of fingerprints. Loops,Whorls,And Arches. Loops-30% Whorls-65% Arches-5%


How many types of storage loops exits in magnetic bubble memory?

There are two types of storage loops exits in magnetic bubble memory.


What are the three main types of fringerprints?

arches, loops and whorls


What are three types of fingerprint patterns?

Loops, whorls and arches.


What are three main types of fingerprints?

There are loops, arches, and swirls


What are arches loops and whirls mean in crime investigation?

They are referring to types of finger prints, generally you either have whirls or arches and loops


Why do you use the loops in java?

You use loops in Java when you want a set of actions to be repeated until a particular condition is met or for a certain number of times.The different types of loops in Java are:For LoopsDo-While LoopsWhile Loops


What types of fabrics do not fray?

Knit fabrics do not fray, because knitted fabric is made of a single strand of yarn with row upon row of loops pulled through loops.


How many types of fingerprints are there?

The fingerprint of every individual is unique, hence it is often used as an identifying factor. There are three main types of fingerprints: whorls, arches and loops.


Are there two types of nephrons which are classified according to their position within the kidney and the lengths of their loops of Henle?

True


What is a loop type?

A Loop is a programming language construct that instructs the processor to repeat a sequence of operations a number of times until a specific condition is reached. There are different types of loops. They are: * for loop * while loop * do while loop