Solved

Need this in basic C , just the solution in text form

Posted on 2000-05-05
3
226 Views
Last Modified: 2010-04-02

Q1:      Write a C program that uses the += operator to accumulate the amount
of water consumed and the distance traveled by a 4 man relay team
in a race. Ask each runner how much water he/she consumed and how
much distance he/she ran and display the results. Additionally,
show the total distance covered and total water consumed by the team.

            


0
Comment
Question by:Real4me
  • 2
3 Comments
 
LVL 1

Expert Comment

by:ntdragon
Comment Utility
we don't do homework at EE
send your code and ask a direct questions
0
 

Expert Comment

by:vl_arunkumar
Comment Utility
Have U tried any code? if so send that and ask the doubt.
0
 

Accepted Solution

by:
vl_arunkumar earned 50 total points
Comment Utility
hello Real4me the following code is the solution for Ur problem



#include<stdio.h>

main()
{
      int i,j;
      float tw=0.0,td=0.0;
      float d[4],w[4];

      printf("Enter no of Players in the Team: ");
      scanf("%d",&j);
      for(i=0;i<j;i++)
      {
            printf("Enter Amount of water consumed by %d :",i+1);
            scanf("%f",&w[i]);
            printf("Enter Amount of distance travelled by %d:",i+1);
            scanf("%f",&d[i]);
      }
      for(i=0;i<j;i++)
      {
            printf("Amount of water consumed by Player     %d: %f\n",i+1,w[i]);
            printf("Amount of Distance travelled by Player %d: %f\n",i+1,d[i]);
            tw+=w[i];
            td+=d[i];
      }
      printf("Total Water consumed by the Team: %f \n",tw);
      printf("Total Distance travelled by the Team: %f\n",td);
}
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now