// Pantea Aria // array of struct - collection of products // write a program that stores information for 5 products using a struct with two fields: // id (integer) // price (double) // After reading the data, your program should: // pass the array to a function to calculate the total price of the 5 products. // display the total #include #define MAX 5 struct product { int id; // id (integer) double price; // price (double) }; void input(int size, struct product numbers[]); double calculate(int size, struct product numbers[]); int main(void) { // declare an array of size MAX of type product struct product products[MAX]; // read information of 5 products input(MAX, products); // call calculate, and return the total price double total_price = calculate(MAX, products); printf ("Total price is %lf\n", total_price); return 0; } void input(int size, struct product numbers[]){ int i = 0; printf ("Enter %d product id and price:", size); while(i < size) { scanf("%d %lf", &numbers[i].id, &numbers[i].price); i++; } return; } double calculate(int size, struct product numbers[]) { double total = 0; int i = 0; while(i < size) { total = total + numbers[i].price; i++; } return total; }