Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C CODE: Relevant Programming Concepts: Dynamic Memory Allocation Problem 1: Use ptr and complete the following program to read and display the data for

IN C CODE:

Relevant Programming Concepts:

Dynamic Memory Allocation

Problem 1: Use ptr and complete the following program to read and display the data for one car from the keyboard

typedef struct {

charbrand[20]; //car brand

char model[20]; //car model

float msrp; //car price

} car;

int main(void){

car *ptr;

// dynamically allocate space for one car variable

//initialize all fields from the keyboard, asking the user to enter relevant data

// print all data on screen

}

Modify your program to ask the user the number of cars (use extra variables) that the user wishes to enter. Allocate an array of cars of the appropriate size and repeat the user data entry. Your program should display all entered users before it terminates.

Sample execution:

Enter the number of cars you would like to enter: 2

Enter the car brand: Toyota

Enter the car model: Avalon

Enter the msrp: 28569

Enter the car brand: BMW

Enter the car model: M3

Enter the car MSRP: 76589

Toyota Avalon $28669

BMW M3 $76589

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions