12 : Write a C program that accepts two item’s weight (floating points' values ) and number of purchase (floating points' values) and calculate the average value of the items.
/*
Write a C program that accepts two item’s weight (floating points' values ) and number of purchase (floating points' values) and calculate the average value of the items.
Test Data :
Weight - Item1: 15
No. of item1: 5
Weight - Item2: 25
No. of item2: 4
Expected Output:
Average Value = 19.444444
*/
#include<stdio.h>
main(void)
{
float Weight_Item1;
printf("Weight - Item1:",Weight_Item1);
scanf("%f",&Weight_Item1);
float No_of_item1;
printf("No. of item1:",No_of_item1);
scanf("%f",&No_of_item1);
float Weight_Item2;
printf("Weight - Item2:",Weight_Item2);
scanf("%f",&Weight_Item2);
float No_of_item2;
printf("No. of item1:",No_of_item2);
scanf("%f",&No_of_item2);
float Average=((Weight_Item1*No_of_item1)+(Weight_Item2*No_of_item2))/(No_of_item1+No_of_item2);
printf("Average Value = %f",Average);
}
Comments
Post a Comment
PLEASE DO NOT ENTER THE SPAM LINK IN THE COMMENT BOX