answersLogoWhite

0

How loops can be beneficial in a program?

Updated: 8/16/2019
User Avatar

Fabulouskemi

Lvl 1
12y ago

Best Answer

you use loops to draw out information from an array or a vector. Also they can be used to count up or down from any giving number.

#include <iostream>

using namespace std;

int main()

{

short a = 1;

short b = 1;

short c = 2;

//do

while (a && b && c != 34);

{

a = c + b;

cout << a << "\n";

b = a + c;

cout << b << "\n";

c = b + a;

cout << c << "\n";

}//while (a && b && c != 34);

return 0;

}

the output of this program would be

3

5

8

13

21

34

if i was to rewrite this program with out the loop, i would have to write the body of the loop

a = c + b;

cout << a << "\n";

b = a + c;

cout << b << "\n";

c = b + a;

cout << c << "\n";

over and over again until i reached the number 34. its adding 1 + 1 = 2

2+1=3, 3+2=5 and so on, that's how the program is reaching 34.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How loops can be beneficial in a program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Give a business example of how loops can be beneficial in a program?

Give a business example of how loops can be beneficial in a program?


Why you use different loops in c language?

We use this in order to make program easier and less complex.some program cannot be performed without loops


Is there another program like Fruity Loops?

Reason is very similar as Fruity Loops, its a better program and takes a little more time to master


Why you use Loops?

Loops are used to repeat the execution of the same set of instructions again and again in a program.


In what instanses can i use the loops?

Whenever there is a repetition in the program.


What are the disadvantages of the While Loop?

With loops, your program is slower.


Can you use two while loops in a program?

You can use zero or more while-loops, there is no limit.


What is a good beat making website?

frutie loops it is a great program


What does it mean to clean out loops in programming?

Cleaning out the loops is essentially removing redundant lines of code in a program. Sometimes having too many of the same codes can slow the program down and cause it to not work as efficiently.


What are the shoulder loops for in boy scouts?

Shoulder loops signify what program the scouts or scouters are in, or if they work at district, council, section, region, or national level.


What do Loops one and two stand for?

I guess they are references to a program list or a figure.


What is the adjective form of beneficial?

The word 'beneficial' is an adjective, a word that describes a noun. Example use:This is a beneficial program for our department.