Question: Q 3 . ( a ) ( i ) Describe the purpose of the following C function. Explain your answer carefully. int f ( int

Q3.(a)(i) Describe the purpose of the following C function. Explain your answer carefully. int f(int n){ int s =0; while (n >0){ s += n%10; n /=10; } return (s); }(ii) Rewrite the following function using a while loop in place of the for loop. What is the purpose of the function? int func(int *x, int n){ int i, y; y = x[0]; for (i=1; i y) y = x[i]; return(y); }(30%)(b) Explain what is meant by type definition and enumeration types in C, with reference to the following line of C code: typedef enum{DEC, NOV, OCT, SEP, AUG, JUL, JUN, MAY, APR, MAR, FEB, JAN} Month; Write a function in C which takes in a single input argument of type Month (as defined above) and returns as output the number of days in that month. Note that the number of days in each month is given by: February: 28 days January, March, May, July, August, October, December: 31 days April, June, September, November: 30 days

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