Practice #3
Lesson 8 of 8 in Coddy's C/C++ Structures course.
Challenge
EasyYou are given a code that initializes N items (Item structure).
Calculate the average price across all the items and output it.
It's the first time you see struct in arrays, but it work just like any other type :)
Try it yourself
#include <stdio.h>
#include <string.h>
struct Item {
char name[30];
int price;
};
int main() {
int N;
scanf("%d", &N);
struct Item items[N];
for (int i = 0; i < N; i++) {
scanf("%s %d", &items[i].name, &items[i].price);
}
// Write code here
return 0;
};