Average Scale

Description:

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. Input Format: Input consists of 5 integers and 1 float. The five integers correspond to s1, s2, s3, s4 and s5. The float input corresponds to x. Output Format: Refer sample input and output for formatting specifications. The float values are displayed correct to 2 decimal places. Sample Input and Output: [All text in bold corresponds to input and the rest corresponds to output] Enter sale in first month 6435 Enter sale in second month 6927 Enter sale in third month 6855 Enter sale in fourth month 7230 Enter sale in fifth month 6562 Enter the average sales in 6 months 6500 The sale in the sixth month is Rs.4991.00

Program :

#include<stdio.h>
int main(){
  float s[5],a;
  scanf("%f",&s[0]);
  scanf("%f",&s[1]);
  scanf("%f",&s[2]);
  scanf("%f",&s[3]);
  scanf("%f",&s[4]);
  scanf("%f",&a);
  printf("sale=%.2f",(6*s[5])-(s[0]+s[1]+s[2]+s[3]+s[4]));  
  return 0;
}