Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1.1 (40 points) Define a structure of student information including student ID, name, age, and score; input the information of N (N=3) students; sort

Exercise 1.1 (40 points)
Define a structure of student information including student ID, name, age, and score; input the information of N (N=3) students; sort the student information in descending order in terms of score and print the student information accordingly.
Hint: use a structure array to store the information of N students; use a sort method, such as bubble sort and selection sort, to sort the array. .
3.2 Definition and usage of pointers
Exercise 1.2 (20 points)
Design a function which can output student information in descending order in terms of score. Structure variables shall be defined as pointer type.
Hint: use the malloc function to allocate memory for structure pointer variable;
3.3 Relationship between pointers and arrays
Exercise1.3 (20 points)
Define a one-dimensional integer array, and a one-dimensional array of student structure; assign the value of integer array element to the score member of the student structure array. Structure pointer variables shall be used to perform the assignment of the structure variables.
Hint: use malloc function to allocate memory for the pointer variables of the student structure. The pointer variable of the structure is pointed to the first element of the student structure array, and use --> to realize the assignment of structure variables.
Exercise 1.4 (20 points)
Define a pointer array to char, where each element of the array is a string, and define a char type double pointer variable. Output the string in the char pointer array in sequential order by using a double pointer.
Attention?
Char *[] is different from char (*)[], the former is a pointer array to char, while the latter is a one-dimensional array pointer to n elements

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

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

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions