Create a c program of your choosing that follows the specifications below:
Code:
#include <stdio.h>
//Defined a struct car with 4 members
struct car{
char maker[100];
char model_name[100];
int model_year;
float price;
};
//Display the data in your array in the terminal (20 points)
//Provide brief comments for every line of code (20 points)
int main(void) {
//Declared an array of struct car with a size of 10
struct car arr[10];
//To read the details from a file crated a file pointer
FILE *fp;
//opend a file named cars_details in read mode
fp = fopen("cars_details.txt","r");
//reading from file and storing in array named arr
for(int i=0;i<10;i++){
fscanf(fp,"%s %s %d %f",arr[i].maker,arr[i].model_name,&arr[i].model_year,&arr[i].price);
}
//printing to terminal
for(int i=0;i<10;i++){
printf("Maker:%s Model:%s Release_year:%d Price:%.2f Lakhs\n",arr[i].maker,arr[i].model_name,arr[i].model_year,arr[i].price);
}
return 0;
}
car_details.txt

output:
Maker:Audi Model:RS7_Sportback Release_year:2019 Price:194.00
Lakhs
Maker:Honda Model:City Release_year:2019 Price:14.64 Lakhs
Maker:Hyundai Model:Tucson Release_year:2019 Price:27.03
Lakhs
Maker:MG Model:Hector_Plus Release_year:2019 Price:18.54
Lakhs
Maker:Honda Model:WR-V Release_year:2019 Price:8.50 Lakhs
Maker:Mercedes-Benz Model:GLS Release_year:2019 Price:100.00
Lakhs
Maker:BMW Model:X6 Release_year:2019 Price:95.00 Lakhs
Maker:Datsun Model:Redi_GO Release_year:4 Price:0.77 Lakhs
Maker:Mercedes-AMG Model:GT Release_year:2019 Price:227.00
Lakhs
Maker:Skoda Model:Superb Release_year:2019 Price:32.99 Lakhs
Create a c program of your choosing that follows the specifications below: Define a struct with...
please help!!! this is VMware Workstation, thank you!
Create a c program of your choosing that follows the specifications below: • Define a struct with 4 or more members. The struct must be different from the ones used in class (20 points) Declare an array of your struct using a size of 10 or more (20 points) Load the data for each element in your array from a text file (20 points) Display the data in your array in the...
Write a C++ Program In C++, struct is a reserved word. Define the struct fruitType. Write a program that declares a variable of type fruitType, prompts the user to input data about a fruit, and outputs the fruit data. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: /* // Name: Your Name // ID: Your ID */ #include <iostream> #include <string> using namespace std; struct...
Exercise #6: ------------ - Define a struct of your own that uses several different data types for the members. {At least 3.} - Create a structure of that type and: - place values into it's members - print the values of each member in the structure - Write a display function that displays the contents of your struct type
C
program
Main topics: Files Program Specification: For this assignment, you need only write a single-file C program. Your program will: Define the following C structure sample typedef struct int sarray size; the number of elements in this sanple's array floatsarray the sample's array of values sample Each sample holds a variable number of values, all taken together constitute a Sample Point Write a separate function to Read a file of delimited Sample Points into an array of pointers to...
***************C PROGRAMMING ONLY************* Demonstrate the ability to create an array on the stack Demonstrate the ability to create an array on the heap allowing user to choose the number of values to store. Demonstrate the ability to store an array of Struct values on both the stack and the heap. Program Specifications: 1. Create a struct with at least 3 fields - any struct you want but explain it in your comments in the code. Populate at least 10 elements...
The language is C++. Code needs to be added to line 28 and 37.
Could someone provide some help with how to do it?
CODE
Write a program to unscramble words A file with list of words is provided along with a template program to get you started. 1. Define a struct with 2 string members: sorted and original 2. Declare an array of 200000 elements with data type of the struct 3. Read from a file a list of...
Activities Define a struct called Unit containing the following fields I Unit code Unit credit hours Unit semester of study List of prerequisites Number of prerequisites List of post requisites Number of post requisites Inside your main function declare an array of type Unit called units with size 20 elements. This array will contain the information related to all the units in our diploma program. Each of the elements of this array correspond with one our diploma units. II III...
Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...
In c++ Write a program that contains a class called Player. This class should contain two member variables: name, score. Here are the specifications: You should write get/set methods for all member variables. You should write a default constructor initializes the member variables to appropriate default values. Create an instance of Player in main. You should set the values on the instance and then print them out on the console. In Main Declare a variable that can hold a dynamcially...
Question: C Programming Problem: Pointer and Struct Description: The purpose of this assignment is to prov... C Programming Problem: Pointer and Struct Description: The purpose of this assignment is to provide practice programming using structs and pointers. Your program will accept user input and store it in a dynamic array of structs. First, you will define a structure to describe a item to be bought. Your program will prompt the user for the initial size of the array. It will...