answersLogoWhite

0

What are the types of loops?

Updated: 8/11/2023
User Avatar

Wiki User

12y ago

Best Answer

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

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

while (expression) statment

for (expression; expression; expression) statement

do statement while (expression) or you can use goto to implement a cycle (don't do that)

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Three looping statements in C language are:

while (expression) statement

for (expression; expression; expression) statement

do statement while (expression)

LABEL: statements go to LABEL

(and of course recursion)

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

while, for, do-while, label-goto

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

The number differs between languages, but the most common are "for", "while", "do", and "each".

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the types of loops?
Write your answer...
Submit
Still have questions?
magnify glass
imp
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 main types of fingerprints?

There are loops, arches, and swirls


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


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.


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


What are the basic parts of the c language?

That would include header files, data types, loops, functions, pointers, arrays