You are on page 1of 3

CONFIDENTIAL QUIZ 1/MAY 2022/CSC404

Quiz 1 - CSC404 – PROGRAMMING II

Name :

Student No. :

Group : CS

Lecturer Name : __________________________________________

Answer all the questions

QUESTION 1

Char string1[10] = “masak”;


Char string2[10] = “masakan”;
Char string3[10] = “masak”;

a. Based on the program segment ablove, what is the output of [3marks]

a) Cout << strcpy (string1, string2) <<string1 <<string2


b) Strcat (string3, string2)
c) Strcmp(string1,string3)

b. Trace the output for the following program: [2 marks]

int number = 18;


int number2 = 2;
int *pointer1 = &number;
int *pointer2 = &number2;
*pointer1 = number*number2;
cout << "Value of pointer1 is :" <<*pointer1 << '\n';

c. Trace the output for the following program: [2 marks]

int value1 = 117;


int value2 = 21;
int value3 = 43;
int *p1 = &value1;

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL TEST 1/NOV 2021/CSC402

int *p2;
int *p3 = &value3;
p2 = &value2;
p2 = p1;
value1 = *p3;
*p2 = *p3;
cout << value1 << value2 << value3;

QUESTION 2

Write a C++ to do the following tasks:

a) The definition of function prototype

void inputMathMarks (float mathmarks[], int n);

This function read n input from user, and store the input in mathmarks [].

2 marks

b) The definition of function prototype

void inputScienceMarks (float sciencemarks[], int n);

This function read n input from user, and store the input in sciencemarks [].

2 marks

c) Based on a) and b), write function definition for

void average (float mathmarks[], float sciencemarks[],


int n, float &highest);

This function will total mathmark and scienceamark to find the average and the highest
average.

5 marks

d) Write the main program to input Math and science marks for 10 students.
e) Call the function average and display the highest average mark for student.

© Hak Cipta Universiti Teknologi MARA 2 CONFIDENTIAL


CONFIDENTIAL TEST 1/NOV 2021/CSC402

4 marks

© Hak Cipta Universiti Teknologi MARA 3 CONFIDENTIAL

You might also like