Uma linha do pedido da padaria é uma struct Item: nome, preço e quantidade. Termine item_total(item) para calcular quanto custa essa linha: levando 3 ou mais, cada um fica 1 mais barato. O main testa duas linhas: 2 bagels e 3 muffins.
bagel: 8 muffin: 12
#include <stdio.h>
struct Item {
const char *name;
int price;
int qty;
};
int item_total(struct Item item) {
int price = item.price;
// seu código aqui: se qty for 3 ou mais, tire 1 de price
return price * item.qty;
}
int main(void) {
struct Item bagels = {"bagel", 4, 2};
struct Item muffins = {"muffin", 5, 3};
printf("%s: %d\n", bagels.name, item_total(bagels));
printf("%s: %d\n", muffins.name, item_total(muffins));
return 0;
}
Executar testa os exemplos. Quando parecerem certos, Enviar.