Computers and Technology

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.\n", studentBirthday. month, studentBirthday. day);

return 0;
}

Question2

Assign Carbonara's data member caloriesPerSlice with 350 and Four Cheese's with 280.

#include
#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\n", availablePizzas[0].pizzaName, availablePizzas[0].caloriesPerSlice );
printf("A %s pizza contains %d calories\n", availablePizzas[1].pizzaName, availablePizzas[1].caloriesPerSlice );

return 0;
}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:00, suyi14
What operating system is a smartphone most likely to use? 1.bsd 2.mac os x 3.symbian 4.linux
Answers: 1
image
Computers and Technology, 22.06.2019 18:00, crimhill
When is it appropriate to use an absolute reference
Answers: 1
image
Computers and Technology, 22.06.2019 20:00, jayjay5246
What is the term for water wave that is created by an underwater earthquake
Answers: 1
image
Computers and Technology, 22.06.2019 21:00, jarrettashlyn
Write a method so that the main() code below can be replaced by the simpler code that calls method original main(): public class calcmiles { public static void main(string [] args) { double milesperhour; double minutestraveled; double hourstraveled; double milestraveled; milesprhour = scnr. nextdouble(); minutestraveled = scnr. nextdouble(); hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; system. out. println("miles: " + milestraveled); } }
Answers: 2
Do you know the correct answer?
C Programming

*Notice: I can only edit the part where it says in /* Your solution goes...

Questions in other subjects:

Konu
Mathematics, 25.10.2019 23:43
Konu
Mathematics, 25.10.2019 23:43