Q:

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

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>
int main() 
   {
	double wi1, ci1, wi2, ci2, result;
    printf("Weight - Item1: ");
	scanf("%lf", &wi1);
	printf("No. of item1: ");
	scanf("%lf", &ci1);
	printf("Weight - Item2: ");
	scanf("%lf", &wi2);
	printf("No. of item2: ");
	scanf("%lf", &ci2);
	result = ((wi1 * ci1) + (wi2 * ci2)) / (ci1 + ci2);
	printf("Average Value = %f\n", result);
	return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Basic Declarations and Expressions exercises

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a C program that accepts an employee's ... >>
<< Write a C program that accepts two integers from t...