LO: (Apply] Students will write loops that iterate over every value in a range. Some marathon organizers are advertising the distances of their races using kilometers. Help them explain the races to participants who are unfamiliar with the metric system. Print a line for each length of race that explains approximately how long it is in miles. The races are organized in increments of 5km. There is a 5km, a 10km, and so on, all the way up to a 40km race. There are approximately 0.621 miles in a kilometer. Miles should be rounded to the nearest whole number. Follow this format: A Skm race is approximately 3 miles long. maln.cpp O O New X Full Screen 1 #include using namespace std; * Displays how long each race is in kilometers and miles. 6. */ 7- int main() { 8 10 11 return 0; 12 } 13
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.
Trending now
This is a popular solution!
Step by step
Solved in 6 steps with 2 images