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 3 basic types of fingerprints and their subcategories?

The three basic types of fingerprints are loops, whorls, and arches. Loops can be further categorized into radial loops and ulnar loops, depending on the direction they flow. Whorls can be classified into plain whorls, central pocket loops, double loops, and accidental whorls. Arches are divided into plain arches and tented arches, characterized by their distinct ridge patterns.


What are three main types of fingerprints?

There are loops, arches, and swirls


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 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


What kind of feed back loops?

Feedback loops can be categorized into two main types: positive feedback loops and negative feedback loops. Positive feedback loops amplify changes or reinforce a process, leading to an increase in the output or effect, such as in population growth. In contrast, negative feedback loops counteract changes, promoting stability and homeostasis within a system, such as in thermoregulation in the human body. Both types are essential for understanding various systems, including ecological, biological, and technological contexts.


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.