//for loop practice /*create a program, called aveRaceTime.cpp, for runners that wish to know their average race time. ask the user how many races they ran, and use their input in your for loop, for the limit on the number of loops (for example, if the user inputs three, that means your for loop should run three times.) Each time the loop runs, it will ask the user what their race time was in minutes. Keep a running total of all of the race times added together. After the loop, compute the user's average race time, and display it in a sentence. Format the average time so it always shows two decimal points.
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
//for loop practice
/*create a
ask the user how many races they ran, and use their input in your for loop,
for the limit on the number of loops (for example, if the user inputs three,
that means your for loop should run three times.) Each time the loop runs, it
will ask the user what their race time was in minutes. Keep a running total of
all of the race times added together. After the loop, compute the user's average race
time, and display it in a sentence. Format the average time so it always shows two decimal points.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images