HCMC UNIVERSITY OF TECHNOLOGY AND EDUCATION Faculty for High Quality Training Program name:_ECET Signature of Proctor Signature of Proctor FINAL EXAMINATION SEMESTER – ACADEMIC YEAR 2018-2019 Course name: C Programming Language Course ID: PRLA335164E Exam code: 01 Number of pages: 06 Duration: 90 minutes Only used one A4-handwriting paper Marks / Signature Signature of Marker Student writes answers directly in space reserved in exam paper and submit back all exam papers Signature of Marker Student name: Student ID: Exam number: Exam room: Question 1: (2.0/10) Give a following program, please perform: #include "stdafx.h" #include // function main begins program execution int main(void) { unsigned int counter; // number of grade to be entered next int grade; // grade value int total; // sum of grades entered by user int average; // average of grades // initialization phase total = 0; // initialize total counter = 0; // initialize loop counter // processing phase while (counter < 5) { // loop times printf("%s", "Enter grade: "); // prompt for input scanf("%d", &grade); // read grade from user total = total + grade; // add grade to total counter = counter + 1; // increment counter } // end while // termination phase average = total / counter; // integer division printf("Class average is %d\n", average); // display result } // end function main a) Draw a flowchart? b) Show contents on the screen after entering numbers as 6, 7, 8, 9, 10? c) Rewrite this program using “do…while”? d) Rewrite this program using “for”? # Question 2: (1.5/10) Show results on the screen after performing a following program: #include void main() { int a[6] = { -2, -1, 0, 1, 2, 3}; int *p1 = &a[1]; int *p2 = &a[2]; *(p1 - 1) = 2**p2 - 4; *p1 = *p2 + 3; *p2 = *(p1 + 4) + *(p2 + 2); ++p2; *(p2 + 2) = a[0] + ++a[1]; *(p2 + 1) = a[2] + a[3]; *p2 = *(p1 + 4) + *(p2 + 2) + 2; printf("%d %d %d %d %d %d", a[0], a[1], a[2], a[3], a[4], a[5]); } Question 3: (1.5/10) Draw flowchart and write a complete program that calculates and prints the product of the odd integers from to Flowchart: Complete program: ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… ………………………………………………… Question 4: (3.0/10) - Edit bugs of a following program (2.0 points): The program Edit bugs #include #include #include int Check(int x) void main(void) { int n, *a, i, flag, max; printf("Input n:” ); scanf("%f", &n); a = (int*)malloc(n, sizeof(int)); for (i = 0; i < n; i++) scanf("%d", *(a + i)); flag = 1; for (i = 0; i < n; i++) if (Check(*(a + i)) == 0) { flag = 0; break; } if (flag == 0) printf("Error data ); else { max = a; for (i = 1; i < n; i++) if (max < *(a + i)) max = *a + i; printf("The maximum number: %d", max); } } int Check(int x) { if (x >= && *x 0) c) Print all information of the base stations on the screen where their capacity values are larger than and equal 2.5 d) Print all information of the best base station on the screen which has the largest capacity value # Note: Proctors are not allowed to give any unauthorized explanation Learning outcome mapping Assessed in [LO 1.1, 1.3]: Draw a flowchart, demonstrate command syntax, operation and application of branching and iteration structures in C language Question 1, [LO 1.5]: Present how the pointer is declared and how to use the pointer to Question 2, 4, retrieve the memory [LO 1.6]: Use function in a program Question [LO 1.7]: Define structure type and use structure variables to store and manage data Question [LO 2.1, 3.1]: Analyze the programming requirements from which to Questions 1, 3, build a flowchart, a complete program; apply control structures, apply data manipulation, build support functions to design and solve application programming requirements 18/12/2018 Approved by program chair (signed and named) ... demonstrate command syntax, operation and application of branching and iteration structures in C language Question 1, [LO 1.5]: Present how the pointer is declared and how to use the pointer to... structure type and use structure variables to store and manage data Question [LO 2.1, 3.1]: Analyze the programming requirements from which to Questions 1, 3, build a flowchart, a complete program; apply... control structures, apply data manipulation, build support functions to design and solve application programming requirements 18/12/2018 Approved by program chair (signed and named)