0% found this document useful (0 votes)
9 views

19-20, HK2_C Programming Language - V5 - Final version -Examcode 1

This document outlines the final examination for the C Programming Language course at HCMC University of Technology and Education for the academic year 2019-2020. It includes various programming quizzes that test students' understanding of C syntax, control structures, and functions, as well as tasks requiring flowchart creation and program development. The exam consists of multiple-choice questions and programming exercises, with specific instructions for students on how to complete and submit their answers.

Uploaded by

23142212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

19-20, HK2_C Programming Language - V5 - Final version -Examcode 1

This document outlines the final examination for the C Programming Language course at HCMC University of Technology and Education for the academic year 2019-2020. It includes various programming quizzes that test students' understanding of C syntax, control structures, and functions, as well as tasks requiring flowchart creation and program development. The exam consists of multiple-choice questions and programming exercises, with specific instructions for students on how to complete and submit their answers.

Uploaded by

23142212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

HCMC UNIVERSITY OF FINAL EXAMINATION

TECHNOLOGY AND EDUCATION


SEMESTER 2 – ACADEMIC YEAR 2019-2020
Faculty for High Quality Training
Course name: C Programming Language
Program name: ECET
Course ID: CPRL130064E
Signature of Proctor 1 Signature of Proctor 2
Exam code: 01 Number of pages: 8
Duration: 90 minutes.
One A4 sheet for notes is allowed.
Marks / Signature Student writes answers directly in space
reserved in exam paper and submit back all
exam papers.
Signature of Marker 1 Signature of Marker 2
Student name:

Student ID:

Exam number:.......... Exam room:

Question 1: Quiz 1 -20 (5/10): Choose the correct answer.


Quiz 1-10: Write the result into the answer area.
Quiz 11-20: Choose the correct answer. Example: Answer: b.

Quiz 1. What is the output of the following Quiz 2. What is the value of S after executing
program: the following code:
#include <stdio.h> float a[4] = {8,16};
void main(void) int S;
{ S = sizeof(a);
int n = 7;
while (n % 3 != 0)
n++;
printf("%d", n);
}
Answer #1: ……………. Answer #2: …………….
Quiz 3. What is the output of the following
program:
#include <stdio.h>
void main(void)
{
int a[] = { 10, 4, 5},n=0;
do{
if (a[n] % 2 == 1)
continue;
printf("%d ", a[n]);
} while (++n < 3); Quiz 4. What is the output of the following
1
} program:
#include <stdio.h>
void main(void)
{
int k = 0, a[] = { 1, 2, 3 }, b = *a;
switch (b)
{
case 0: ++k;
case 1: k += 2;
case 2: k++; break;
default: k += 3; break;
}
printf("%d", k);
}
Answer #3: ………………. Answer #4: ………….

Quiz 5. What is the output of the following Quiz 6. What is the output of the following
program: program:
#include <stdio.h> #include <stdio.h>
int main() void main(void)
{ {
int a[10] = {3, 10, 4, 5, 6, 45, 2, 23, 19, 9}, hold; int n = 2;
for (int pass = 1; pass < 10; ++pass) { for (n = 1; n <5; n += 2)
for (int i = 0; i < 9; ++i) { {
if (a[i] > a[i + 1]) { printf("%d ", ++n);
hold = a[i]; }
a[i] = a[i + 1]; }
a[i + 1] = hold;
}
}
}
printf("%d", a[0]);
return 0;
}
Answer #5: ……………. Answer #6: …………….

Quiz 7. What is the output of the following Quiz 8. What is the output of the following
program: program:
#include <stdio.h> #include <stdio.h>
void main(void) void main(void)
{ {
2
int n = 6; int a[6] = { 10, 15, 6, 4, 5, 45};
do for (int n = 0; n <6; n++)
{ {
printf("%d ", --n); printf("%d ", a[n]);
} while (n > 2); if (n % 2 == 0)
} break;
}
}
Answer #7: ……………. Answer #8: …………….
Quiz 9. What is the output of the following Quiz 10. What is the output of the following
program: program:
#include <stdio.h> #include <stdio.h>
void main(void) int func(int x);
{ void main(void)
int a = 1, b = 2, c = 3; {
if ((a <= b) && (b > c)) int a = 8, b = 9;
{ a = c - b; b = func(a);
++b; printf("%d, %d", a, b);
} }
else
{ b = a + c; int func(int x)
++a; {
b--; x--;
} return x/2;
printf("%d, %d", a, b); }
}
Answer #9: ……………. Answer #10: …………….

Quiz 11. What is the output of the following Quiz 12. What is the output of the following
3
program: program:
#include <stdio.h> #include <stdio.h>
int CountCharacters(const char *sPtr); int func(int *m, int *n)
int main(void) {
{ if (*m > *n) return *n;
char string[] = "C Programming Language"; return *m;
printf("%d", CountCharacters(string)); }
return 0; void main()
} {
int CountCharacters(const char *sPtr) int x = 5, y = 3;
{ printf("%d", func(&x, &y));
int t = 0; }
for (; *sPtr != '\0'; sPtr++) { a. 5
if (*sPtr == 'a') t += 1; } b. 3
return t; c. 5, 3
} d. 3, 5
a. 0 e. Other answers
b. 1
c. 3
d. a
e. Other answers
Answer #11: ……………. Answer #12: …………….
Quiz 13. What is the output of the following Quiz 14. What is the output of the following
program: program:
#include <stdio.h> #include <stdio.h>
struct Student struct Student
{ {
char FL[30]; char FL[10];
char ID[30]; char ID[10];
float MidE; float MidE;
float FinalE; float FinalE;
float AP; float AP;
}; };
void main() void main()
{ {
struct Student S = {"abc","19141102",5.5,6}; struct Student S = {"abc","19141102",7,9};
S.AP += (S.MidE + S.FinalE) / 2; struct Student *Sptr;
printf("%s: %0.2f= %0.1f", S.FL, S.AP, S.AP); Sptr = &S;
} Sptr->AP += (Sptr->MidE + Sptr->FinalE) / 2;
printf("%s: %0.1f", Sptr->ID, Sptr->AP);
}
4
a. abc: 5.75= 5.8 a. 19141102: 8
b. abc: 5.5= 6 b. 19141102: 8.0
c. 19141102: 5.50= 6.0 c. abc: 8.0
d. Other answers d. Other answers
Answer #13: ………………. Answer #14: ……………….
Quiz 15. In the variable names as follows, which Quiz 16. Which of the following operators is a
name is TRUE according to C syntax: non-equal comparison operator?
a. -bien123 a. !
b. 12Bien b. !=
c. _172 c. /=
d. Other answers d. ~=
e. Other answers
Answer #15: ……………. Answer #16: …………….
Quiz 17. What is the output of the following Quiz 18. What is the output of the following
program: program:
#include <stdio.h> #include <stdio.h>
void func(int *n, int *m) int main()
{ {
int a; int a[5] = {1, 2, 3, 4, 5};
a = *n - 8; int *p1 = &a[0];
*n = *m + 7; int *p2 = &a[1];
*m = a; *p1 = *p2;
} *(p1 + 1) = *p1 + 1;
void main(void) p2+=2;
{ *(p2 - 1) = *p1 + 2;
int i, a[4] = { 2, 3, 4, 7 }; *p2 = *(p2 + 1) + 3;
func(&a[1], &a[2]); printf("%d, %d", a[1], a[2]);
printf("%d, %d", a[1], a[2]); return 0;
} }
a. -8, 7 a. 3, 3
b. 3, 4 b. 4, 3
c. -5, 11 c. 3, 4
d. 11, -5 d. 4, 4
e. Other answers e. Other answers
Answer #17: ……………. Answer #18: …………….
Quiz 19. What is the output of the following Quiz 20. What is the output of the following
program: program:
#include <stdio.h> #include <stdio.h>
void func(void); #include <malloc.h>
void main(void) void main(void)
{ {
5
func(); int *a, k;
func(); a = (int*)malloc(3*sizeof(int));
} for (k = 0; k < 3; k++)
void func(void) *(a+k) = k+1;
{ printf("%d", *(a+1));
static int x = 20; free(a);
printf("%d ", x++); }
} a. 0
a. 20 20 b. 1
b. 20 21 c. 2
c. 20 d. 3
d. 21 e. Other answers
e. Other answers
Answer #19: ……………. Answer #20: …………….

Question 2: (2/10) Draw flowchart and write a complete program that solves a sum as

where: n is a positive integer number n (n>0) and is entered from the keyboard.

.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................

6
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
Question 3: (3/10) By using the pointers and functions, write a complete program to do the
following tasks:
a) A function which enters values for a positive-float point array with 50 elements, the array
is named as P[50].
b) A function which enters values for a positive-integer credit array with 50 elements, the
array is named as C[50].
c) A function which calculates a cumulative mean point by a following formula

d) A main function which calls the above functions to print the cumulative mean point M.
e) Count the number of the elements in the point array P[50] that the value of these elements
is larger than 7.
f) Sort and export the point array P[50] in ascending order.
g) Export the maximum value and the minimum value in the point array P[50].

.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
7
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................

Note: Proctors are not allowed to give any unauthorized explanation.


Learning outcome mapping Assessed in
[G1.2, G1.3]: Present and apply the syntax and operation of statements. Question 1
[G3.1]: Create flowchart, apply control structures and data manipulation, build Questions 2,
support functions to design and solve application programming requirements. 3

22/07/2020
Approved by program chair

You might also like