Computer Science, asked by Poorva6348, 11 months ago

A grocer has a sale of rs. s1, rs. s2, rs. s3, rs. s4 and rs. s5 for 5 consecutive months. how much sale must he have in the sixth month so that he gets an average sale of rs. x? write a c program to compute the sale in the 6th month.

Answers

Answered by meeraasrinivas
3

Computation:

Average sale for 6 months = Sum of monthly sales/6

x = (s1 + s2 + s3 + s4 + s5 + s6) / 6

Sale of 6th month, s6 = 6x - s1 -s2 - s3 - s4 - s5

or s6 = 6x - (s1 + s2 + s3 + s4 + s5)

C-program:

#include <stdio.h>

int main()

{

float s1, s2, s3, s4, s5, s6,x;

printf("Enter the sales of first 5 months");

scanf("%f %f %f %f %f",&s1, &s2,&s3,&s4,&s5);

printf("Enter the average sales for 6 months");

scanf("%f",&x);

s6 = (6*x) - (s1 + s2 + s3+s4+s5);

printf("The sale of 6th month is Rs.%f",s6);

return 0;

}



Answered by tanvigupta426
0

Answer:

C Program is a high-level and general-purpose programming terminology that exists perfect for generating firmware or portative applications.

Explanation:

Given :

A grocer has a sale of rs. s1, rs. s2, rs. s3, rs. s4 and rs. s5 for 5 consecutive months.

To find:

  • how much sale must he have in the sixth month so that he gets an average sale of rs. x
  • write a c program to compute the sale in the 6th month

Average sale for 6 months

The average sale for 6 months = \frac{Sum of monthly sales}{6}

x = \frac{(s1 + s2 + s3 + s4 + s5 + s6)}{6}

Sale of 6th month, s6 = 6x – s1 -s2 – s3 – s4 – s5

or

s6 = 6x – (s1 + s2 + s3 + s4 + s5)

Therefore, the average sale for six months,

s6 = 6x – s1 -s2 – s3 – s4 – s5

C Program

#include <stdio.h>

int main()

{

float s1, s2, s3, s4, s5, s6,x;

printf(“Enter the sales of first 5 months”);

scanf(“%f %f %f %f %f”,&s1, &s2,&s3,&s4,&s5);

printf(“Enter the average sales for 6 months”);

scanf(“%f”,&x);

s6 = (6*x) - (s1 + s2 + s3+s4+s5);

printf(“The sale of 6th month is Rs.%f”,s6);

return 0;

}

#SPJ3

Similar questions