Question
C Programming *Notice: I can only edit the part where it says in /* Your solution goes here */ the other part of the code
C Programming
*Notice: I can only edit the part where it says in /* Your solution goes here */ the other part of the code i can't touch it please the solution should be inside that part ad using the code provided
Question 1
Define a function SetBirth, with int parameters monthVal and dayVal, that returns a struct of type BirthMonthDay. The function should assign BirthMonthDay's data member month with monthVal and day with dayVal.
#include
typedef struct BirthMonthDay_struct { int month; int day; } BirthMonthDay;
/* Your solution goes here */
int main(void) { BirthMonthDay studentBirthday; int month; int day;
scanf("%d %d", &month, &day); studentBirthday = SetBirth(month, day); printf("The student was born on %d/%d. ", studentBirthday.month, studentBirthday.day);
return 0; }
Question2
Assign Carbonara's data member caloriesPerSlice with 350 and Four Cheese's with 280.
#include
typedef struct PizzaInfo_struct { char pizzaName[30]; int caloriesPerSlice; } PizzaInfo;
int main(void) {
PizzaInfo availablePizzas[2];
strcpy(availablePizzas[0].pizzaName, "Carbonara"); strcpy(availablePizzas[1].pizzaName, "Four Cheese");
/* Your solution goes here */
printf("A %s pizza contains %d calories ", availablePizzas[0].pizzaName, availablePizzas[0].caloriesPerSlice); printf("A %s pizza contains %d calories ", availablePizzas[1].pizzaName, availablePizzas[1].caloriesPerSlice);
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started