Solved

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

Posted on 2000-05-05
3
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Expert Comment

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

Expert Comment

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

Accepted Solution

by:
vl_arunkumar earned 50 total points
ID: 2820166
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

717 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