Code in c language, please. Thank you in advance. Assign listOfPizzas's first element's numberOfCalories with the value in listOfPizzas's second element's numberOfCalories. #include #include typedef struct Pizza_struct { char pizzaName[75]; int numberOfCalories; } Pizza; int main(void) { Pizza listOfPizzas[2]; scanf("%s", listOfPizzas[0].pizzaName); scanf("%d", &listOfPizzas[0].numberOfCalories); scanf("%s", listOfPizzas[1].pizzaName); scanf("%d", &listOfPizzas[1].numberOfCalories); /* Your code goes here */ printf("A %s slice contains %d calories.\n", listOfPizzas[0].pizzaName, listOfPizzas[0].numberOfCalories); printf("A %s slice contains %d calories.\n", listOfPizzas[1].pizzaName, listOfPizzas[1].numberOfCalories); return 0; }
Code in c language, please. Thank you in advance. Assign listOfPizzas's first element's numberOfCalories with the value in listOfPizzas's second element's numberOfCalories.
#include <stdio.h>
#include <string.h>
typedef struct Pizza_struct {
char pizzaName[75];
int numberOfCalories;
} Pizza;
int main(void) {
Pizza listOfPizzas[2];
scanf("%s", listOfPizzas[0].pizzaName);
scanf("%d", &listOfPizzas[0].numberOfCalories);
scanf("%s", listOfPizzas[1].pizzaName);
scanf("%d", &listOfPizzas[1].numberOfCalories);
/* Your code goes here */
printf("A %s slice contains %d calories.\n", listOfPizzas[0].pizzaName, listOfPizzas[0].numberOfCalories);
printf("A %s slice contains %d calories.\n", listOfPizzas[1].pizzaName, listOfPizzas[1].numberOfCalories);
return 0;
}
Step by step
Solved in 3 steps with 1 images