You are on page 1of 8

XIAMEN UNIVERSITY MALAYSIA

ONLINE FINAL EXAMINATION

Course Code: FSC111


Course Name: Programming Language C
Question Paper
Wang Yiju
Setter:
Academic Session: 2021/04 Question Paper: A  B 
Total No. of Pages: 8 Time Allocated: 2 hours
Additional Materials: -
Apparatus Allowed: -

INSTRUCTIONS TO CANDIDATES

1. This paper consists of 1 Section(s):


Section A: 5 question(s)
Answer all questions.
2. Please follow the requirement of each section and type in all the corresponding answers
on the downloadable answer book provided.

3. Communication between candidates in any means is forbidden. Answers must be entirely


individual candidate’s independent effort. If you are found sharing your solutions with
other candidates, or suspected of doing so, you would be penalized accordingly.

(Student ID: Full Name: )


CONFIDENTIAL 202104/FSC111/A

Section A (100 marks)


Coding

Question 1 (20 marks) (4 marks each)


Write a single statement to accomplish each of the following.
(a) Define the variable aptr to be a pointer to an object of type double.
(b) Print 678.123456 in exponential notation with a sign (+ or -) and 3 digits of precision.
(c) Read a string into character array string1.
(d) Assign the value of the object pointed by aptr to variable b.
(e) Define an array called max with SIZE elements of type float and initialize the elements
to 0.

Page 1 of 97
CONFIDENTIAL 202104/FSC111/A

Question 2 (15 marks)


Complete the following coding to key in 3 integers from keyboard, check how many zero(s)
are there, and
(a) if the number of zeros is none, calculate the sum of these three integers and print the sum,
(b) if only one integer is zero, print the sentence “Among these three integers, only one is
zero.” on the computer screen, and
(c) in all any other cases, assign all these three integers to be the integer one and print the
sentence “All other cases are so funny!”.

#include <stdio.h>

int main()
{
int number[3], n=0;

switch(n)
{

}

}

Examples of the results are as follow. Please solve the problem with switch…case statement
to have different branches and follow the input and output format of the results as shown
below.

Page 2 of 97
CONFIDENTIAL 202104/FSC111/A

Question 3 (15 marks)

Write a program to input the number of row(s) m and the number of column(s) n from
keyboard, then get the m× nmatrix a. Each element’s value in the matrix a should satisfy
a [ i ][ j ] =2 ×i+3 × j

where, 1 ≤i ≤m , 1≤ j ≤n. Examples of the results are as follow. Please solve the problem with
nested while loop (Both inner loop and outer loop are both while loop), and follow the input
and output format of the results as shown below.

Page 3 of 97
CONFIDENTIAL 202104/FSC111/A

Question 4 (20 marks)


Complete the following program to input some characters from keyboard (Until the input
character is newline \n, stop inputting), then count the number of letters and the number of
digits in the string.

Examples of the results are as follow. Please solve the problem with function(s) and follow
the input and output format of the results as shown below.

Question 5 (30 marks)

Write a program to input each staff’s information of a company (Including name, status of
Covid-19 vaccination (As shown in table.1), and age), then for those who have completed the
2nd dose of Covid-19 vaccination, list their names and calculate their average age, assuming
the company has 5 staffs. (Please ignore the case that no one has completed the 2 nd dose of
Covid-19 vaccination.)

Remark Status (One character )


Staff without Covid-19 vaccination A
Staff who has completed the 1st dose of B
Covid-19 vaccination
Staff who has completed the 2nd dose of C
Covid-19 vaccination
Table.1

Page 4 of 97
CONFIDENTIAL 202104/FSC111/A

Examples of the results are as follow. Please solve the problem with structure(s) and
function(s), and follow the input and output format of the results as shown below.

Page 5 of 97
CONFIDENTIAL 202104/FSC111/A

Page 6 of 97
CONFIDENTIAL 202104/FSC111/A

- END OF PAPER -

Page 7 of 97

You might also like