1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
morpeh [17]
3 years ago
10

An athlete runs every day for five days. Write a program that computes the total distance and average distance ran by the athlet

e. 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.
Computers and Technology
1 answer:
Tamiku [17]3 years ago
5 0

Answer:

// 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

You might be interested in
How do I take off the header off my second page in google docs ? ( I only need it on page 1)
iragen [17]
You cant headers are applied to every page. Apply your header under the header
3 0
3 years ago
Read 2 more answers
You should always be afraid to use the internet<br><br> True or false?
ch4aika [34]

Answer:

false

Explanation:

you should be but in the same time no

7 0
3 years ago
The device that store data and program for current purpose​
Musya8 [376]

Answer:

A computer, what you are using. smh.

6 0
3 years ago
Read 2 more answers
Electricity is moved from place to place a long __________​
nexus9112 [7]

Answer:

current of electricity

Explanation:

hope it will help full to you

6 0
3 years ago
Read 2 more answers
What is renewable energy
Marat540 [252]
Renewable energy is energy that is collected from renewable resources, which are naturally replenished on a human timescale, such as sunlight, wind, rain, tides, waves, and geothermal heat.
8 0
3 years ago
Other questions:
  • Which activity cannot be done on a social networking site?
    12·1 answer
  • Which is an example of withholding you might see on your pay stub
    14·2 answers
  • How many questions must you answer in Brainly to be able to message people?
    6·2 answers
  • Mr. Mathis asked his students to add a comment to a cell the students recorded the steps they followed in a chart. Which student
    12·2 answers
  • Before its final commercial release, a(n) ________ version of software may be offered to certain test sites or to interested use
    6·1 answer
  • Which type of computer graphic can be blown up to a much larger size without getting distorted or losing quality?
    5·1 answer
  • which of the following cells can't be recarged? A. Electrode cell B. wet cell C. primary cell D. storage cell
    13·1 answer
  • What was that show where lowe’s were based off eye colors and the main character had orange eyes that let her mind control peopl
    14·2 answers
  • 19. Fatigue can help improve your reaction time.<br> False<br> O True
    8·2 answers
  • what must you consider when determining the efficiency of an algorithm? select two choices. group of answer choices the amount o
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!