Question: #include / / Step 1 : Define a C struct named Car that has three members: make ( string ) , model ( string )

#include // Step 1: Define a C struct named Car that has three members: make (string), model (string), and year (int). typedef struct Car { char make[50]; char model[50]; int year;} Car; // Step 2: Write a function prototype for printCarInfo, which takes a Car struct as a parameter and returns no value. void printCarInfo(Car car); // Step 3: Implement the function printCarInfo you declared in Step 2. The function should print the car's make, model, and year in the format: "Make: [make], Model: [model], Year: [year]". void printCarInfo(Car car){ printf("Make: %s, Model: %s, Year: %d
", car.make, car.model, car.year); } int main(){ Car myCar ={"Toyota", "Corolla", 2020}; printCarInfo(myCar); return 0; } add Step 4: Create and Use a Car Struct - this code should be in the main() function. Create an instance of the Car struct named myCar, initialize it with the make "Toyota", the model "Corolla", and the year 2020. Then, call the printCarInfo function using myCar as the argument. Step 5: Modify the Struct in a Function - No need for main() function code Write a function named updateCarYear that takes a Car struct as a reference and an integer newYear. The function should update the year of the car to newYear and then print the updated information using printCarInfo.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!