Need this in basic C , just the solution in text form
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.
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);
}
#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);
}