what are loops | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what are loops

11th Aug 2016, 12:41 AM
Cam Graves
Cam Graves - avatar
2 Answers
+ 1
A loop is a function that continues to run until a certain condition evaluates to false. while() is a loop. Example: int x = 0; while (x != 6) { std::cout << x << "\n"; x++; } Output will be: 0 1 2 3 4 5 for() is also a loop. Example: int x = 1; for (int y = 1; y <= 5; y++) { std::cout << x << "\n"; x *= y; } Output will be: 1 2 6 24 120
11th Aug 2016, 12:54 AM
Cohen Creber
Cohen Creber - avatar
0
loops are used in program when u need to print a thing or perform operation continuously
11th Aug 2016, 9:30 AM
PRANJAL AGNIHOTRI
PRANJAL AGNIHOTRI - avatar