The family is off on a trip; each suitcase is a struct Bag: whose it is and how many kilos. Write total_kg(bags, n) to add up the kilos of the n bags. No bags gives 0.
total_kg({{"Ana", 18}, {"Ben", 23}}, 2)→41total_kg({{"Kai", 7}}, 1)→7int total_kg(struct Bag bags[], int n)struct Bag {
const char *owner;
int kg;
};
int total_kg(struct Bag bags[], int n) {
int total = 0;
for (int i = 0; i < n; i++) {
// your code here: add bag i's kg to total
}
return total;
}
Run tries the examples. When they look right, Submit.