Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C programming. 1.Create a program that does the following - Creates three pointers, a character pointer professor, and two integer pointers student_ids, grades - Using

C programming.

1.Create a program that does the following - Creates three pointers, a character pointer professor, and two integer pointers student_ids, grades - Using dynamic memory, use calloc to allocate 256 characters for the professor pointer - Prompts the professor for their name, and the number of students to mark. - Stores the professors name using the professor pointer and in an integer the number of students to mark. - Using dynamic memory, use malloc to allocate memory for student_ids and grades to hold the number of students the professor needs to mark. - The program does not need to do anything else, ensure that you free your memory before terminating. - You will need to review the malloc, calloc, and sizeof documentation.

2. Building upon the previous questions you will create a marking system for professors at UOIT. - Structs can be used the same as any other data type in C, instead of having two arrays for the grades and student ids create a struct called grade that contains two integers: student_id and mark. - Create a function grade_students which takes the following arguments: a pointer to the grade struct called grades, and an integer num_students. The function returns void and does the following: - Opens the file grades.txt in write mode - Using the num_students parameter iterates through all of the grade structs pointed to by the grades parameter (remember arrays are pointers, you can treat pointers like arrays). - For each grade structure adds the mark member of the struct to a variable called sum that holds the sum of all students grades. - For each grade structure write to the file grades.txt the student id and the mark on a single line.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions