lisbethtsu5309
23.09.2019 •
Computers and Technology
An athlete runs every day for five days. write a program that computes the total distance and average distance ran by the athlete. the program should ask the user for the number of miles run on each day (monday to friday), and save the values entered by the user in five different variables. the program should first calculate the total miles ran by the athlete and store the result in a variable named sum. then the program should compute the average distance covered and store it in a variable named average. display the total distance and the average distance on the screen. name your program file hw1_q1_code.c.
Solved
Show answers
More tips
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
- H Health and Medicine Kinesiology: What is it and How Does it Work?...
- O Other How to Choose the Best Answer to Your Question on The Grand Question ?...
- L Leisure and Entertainment History of International Women s Day: When Did the Celebration of March 8th Begin?...
- S Style and Beauty Intimate Haircut: The Reasons, Popularity, and Risks...
- A Art and Culture When Will Eurovision 2011 Take Place?...
- S Style and Beauty How to Choose the Perfect Hair Straightener?...
Answers on questions: Computers and Technology
- E English A poster on the wall that names and defines the parts of speech. a. To entertain b. To inform c. To persuade...
- M Mathematics This is absolute value . Please help !!...
- M Mathematics Why is stephan wrong? Please explain why....
- M Mathematics System of Linear Equations Project Introduction 1. Spending nights at a 3 star hotel in Paris, France or spending nights at a 5 star hotel in Atlanta, GA. Vacation Situation:...
Ответ:
// here is Hw1_q1_code.c
#include <stdio.h>
// main function
int main(void) {
// variables
float dis_mon,dis_tue,dis_wed,dis_thu,dis_fri;
printf("enter distance ran by athlete on monday:");
// read distance on monday
scanf("%f",&dis_mon);
printf("enter distance ran by athlete on tuesday:");
// read distance on tuesday
scanf("%f",&dis_tue);
printf("enter distance ran by athlete on wednesday:");
// read distance on wednesday
scanf("%f",&dis_wed);
printf("enter distance ran by athlete on thursday:");
// read distance on thursday
scanf("%f",&dis_thu);
printf("enter distance ran by athlete on friday:");
// read distance on friday
scanf("%f",&dis_fri);
// total distance
float sum=dis_mon+dis_tue+dis_wed+dis_thu+dis_fri;
// average distance
float average=sum/5;
// print the total and average
printf("total distance ran by athlete is: %f miles",sum);
printf("\naverage distance ran each day is: %f miles",average);
return 0;
}
Explanation:
Declare five variables to store distance ran by athlete on each day from monday to friday.Read the five distance.Then calculate their sum and assign to variable "sum".Find the average distance ran by athlete by dividing sum with 5 and assign to variable "average".Then print the total distance ran and average distance on each day.
Output:
enter distance ran by athlete on monday:10
enter distance ran by athlete on tuesday:11
enter distance ran by athlete on wednesday:8
enter distance ran by athlete on thursday:9
enter distance ran by athlete on friday:12
total distance ran by athlete is: 50.000000 miles
average distance ran each day is: 10.000000 miles
Ответ:
Answer is in a file below
cutt.us/tWGpn