HCMC UNIVERSITY OF TECHNOLOGY AND EDUCATION FINAL EXAMINATION SEMESTER – ACADEMIC YEAR 2019-2020 Course name: C Programming Language Course ID: PRLA335164E Exam code: 03 Number of pages: Duration: 90 minutes Faculty for High Quality Training Program name: ECET Signature of Proctor Signature of Proctor One A4 sheet for notes is allowed Marks / Signature Signature of Marker Student writes answers directly in space reserved in exam paper and submit back all exam papers Student name: Signature of Marker Student ID: Exam number: Exam room: Question 1: Quiz -20 (5/10): Choose the correct answer Quiz In the C program, which of the following statements is possible to enter an integer from the keyboard and save it to an integer variable a? a scanf("Enter value of a: %d",&a); b scanf("%d",&a); c scanf("Enter value of a: %d",a); d scanf("%d",a); Quiz What is the value of S after executing the following code: float c[8] = { 24 }; int S; S = sizeof(c); a Other answers b c 24 d 32 Answer #1: …………… Answer #2: …………… Quiz In the C program, which of the following statements is used to print value of an integer variable a? a printf ("value of a: %d", a); b printf ("value of a: ", %d , a); c printf ("value of a: %d , a"); d printf ("value of a: a", %d ); Quiz What is the output of the following program: #include int main() { char a[15] = "hello"; int S, i; for (i = 0; i < 15;i++) if (a[i] == '\0') { S = i; break; } printf("%d", S); getchar(); } a b c d e Answer #3: …………… 15 Other answers Answer #4: …………… Quiz In the C language, how many bytes is the Quiz What is the output of the following variable a created with the following statement? program: #include double a = 2; void main(void) { a byte int n = 8; b 10 byte while (n % != 0) c byte n; d byte printf("%d", n); e Other answers } a b c d e Other answers Answer #5: …………… Answer #6: …………… Quiz What is the output of the following program: #include void main(void) { int n = 4; { printf("%d ", n ); } while (n > 0); } Quiz What is the output of the following program: #include void main(void) { int n = 4; for (n = 6; n > 1;n-=2) { printf("%d ", n ); } } a b c d Other answers e a b c d e Other answers 4 Answer #7: …………… Answer #8: …………… Quiz What is the output of the following program: Quiz 10 What is the output of the following #include void main(void) { int a = 1, b = 2, c = 3, d = 4, e = 5; if ((a c) || (d < e)) { a = c - b; a += e; e += a; d++; d *= b; ++b; } else { b = a + c; ++a; d = a + e; c = b + d; b ; } printf("%d, %d", a, b); } a 3, b 6, c 63 d Other answers program: #include int hamc(int x); void main(void) { int a = 11, b = 8; b = hamc(a); printf("%d and %d", a, b); } Answer #9: …………… Answer #10: …………… int hamc(int x) { ++x; return(x % 2); } a 11 and b 12 and c 11 and d Other answers Quiz 11 What is the output of the following Quiz 12 What is the output of the following program: program: #include int Func(int *a) void main(void) { { if (*a>0) int i = 0, c[] = { 1, 2, }, b = *(c+1); { switch (b) *a += 1; return 2; { } case 1: i += 1; else case 2: i = i + 2; break; { case 3: i++; *a -= 1; return 3; default: i += 3; } } } printf("%d", i); void main() } { int S = 1; a b c d Other answers S=Func(&S); printf("%d", S); } a b c d e -1 Other answers Answer #11: …………… Answer #12: …………… Quiz 13 What is the output of the following program: #include #include void main(void) { struct DIEMTHI { char c; int d, d1, d2; } m = { 'C', 11, 2, }; m.d += 3; ++m.d2; printf("%c%d%d%d", m.c, m.d, m.d1, m.d2); } a C1421 b C112 c 1421C d Syntax error e Other answers Quiz 14 What is the output of the following program: #include #include void main(void) { int *a, S = 0, n = 3, i; a = (int*)malloc(n*sizeof(int)); for (i = 0; i < n; i++) *(a + i) = S + i; S = *(a + 2); printf("%d", S); } a Other answers b c d e Answer #13: …………… Answer #14: …………… Quiz 15 What is the output of the following Quiz 16 What is the output of the following program: program: #include #include void func(int *n, int *m) int func(int k); { int main() int a; { a = *n - 9; *n = *m + 9; *m = a; int n=5, S; } S = func(n); void main(void) printf("%d", S); { return 0; int i, a[4] = { 1, 3, 5, }; } func(&a[1], &a[2]); printf("%d, %d", a[1], a[2]); int func(int k){ int temp = 0; int j; for (j = 1; j