Question: 1. Look at the code below. Describe how the malloc function is used. What does the free function do? #include struct rec int i; float

1. Look at the code below. Describe how the malloc function is used. What does the free function do?

#include

struct rec

int i;

float PI;

char A;

int main()

struct rec *ptr_one;

ptr_one = (struct rec *) malloc (sizeof(struct rec));

ptr_one->i = 10;

ptr_one->PI = 3.14;

ptr_one->A = a;

printf(First value: %d , ptr_one->i);

printf(Second value: %f , ptr_one->PI);

printf(Third value: %c , ptr_one->A);

free(ptr_one);

return 0;

}

2. You are to write a program that will use a linked list to store student information of three students. The information about each student consists of i) Student First Name, ii) Student last name, iii) Student id number, and iv) Students major. Develop a structure that will be used to build the list.

3. Write a program that will calculate the factorial of a positive integer n (n!). The program should receive the integer using command line arguments. Use a recursive function to compute the factorial value.

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 Databases Questions!