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

Sample MCQ CBCP2202

This document contains a 3 sentence multiple choice quiz with 6 questions about programming concepts like loops, functions, and file input/output. It provides reminders to read instructions carefully and includes the questions in both English and Malay. The questions cover topics such as the number of iterations in a for loop, the purpose of continue statements, function output, and different types of functions and ways of reading from text files.

Uploaded by

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

Sample MCQ CBCP2202

This document contains a 3 sentence multiple choice quiz with 6 questions about programming concepts like loops, functions, and file input/output. It provides reminders to read instructions carefully and includes the questions in both English and Malay. The questions cover topics such as the number of iterations in a for loop, the purpose of continue statements, function output, and different types of functions and ways of reading from text files.

Uploaded by

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

SAMPLE CBCP2202

REMINDER: READ CAREFULLY THE INSTRUCTIONS ON THE FRONT PAGE.


PERINGATAN: BACA DENGAN TELITI ARAHAN PADA MUKA SURAT HADAPAN.

1. Based on the given for statement, how many times is the loop executed?
for (x = 10; x > 2; x--)

A. 6
B. 7
C. 8

Berdasarkan kepada pernyataan for yang diberikan ini, berapa kalikah gelung dilaksanakan?
for (x = 10; x > 2; x--)

A. 6
B. 7
C. 8

2. What is the purpose of continue statement?

A. Resume the program when it has stopped.


B. Resume the program if a break statement is given.

C. Skip the test of the statements of the loop in the current iteration.

Apakah tujuan pernyataan continue?

A. Meneruskan aturcara apabila ianya terhenti.


B. Meneruskan aturcara jika pernyataan break diberikan.

C. Langkau ujian bagi penyataan gelung dalam lelaran semasa.

3. What will be the output of the following program?


#include <stdio.h>
int main()
{
double price=9.90;
if(price >= 9.00)
printf("Affordable price\n");
else
printf("It doesn't matters\n");
return 0;
}
A. Affordable price
B. It doesn't matters
C. No output

Apakah output dari program berikut?

Page 1 of 3
SAMPLE CBCP2202

#include <stdio.h>
int main()
{
double price=9.90;
if(price >= 9.00)
printf("Affordable price\n");
else
printf("It doesn't matters\n");
return 0;
}
A. Affordable price
B. It doesn't matters
C. Tiada output

4. The following code has a function myFunc that will receive an integer and display it. What is
the output of the program?
void myFunc(int x){
if(x>4) {
myFunc(--x);
printf(“%d”, x);
}
}
int main() {
myFunc(5);
return 0;
}

A. 3
B. 4
C. 5

Kod berikut mempunyai satu fungsi myFunc yang akan menerima suatu integer dan
memaparkannya. Apakah output aturcara ini?
void myFunc(int x) {
if(x>4) {
myFunc(--x);
printf(“%d”, x);
}
}
int main()
{
myFunc(5);
return 0;

Page 2 of 3
SAMPLE CBCP2202

A. 3
B. 4
C. 5

5. Which of the following is considered as one of the types of function?

A. Function without returned data type and without parameter.


B. Function with returned data type.
C. Function without returned data type.

Manakah antara berikut dipertimbangkan sebagai salah satu jenis fungsi?

A. Fungsi tanpa jenis data dikembalikan dan tanpa parameter.


B. Fungsi dengan jenis data dikembalikan.
C. Fungsi tanpa jenis data dikembalikan.

6. Choose the function which reads data from a text file.

A. read
B. fscanf
C. readln

Pilih fungsi yang membaca data daripada fail teks.

A. read
B. fscanf
C. readln

END OF QUESTION PAPER / KERTAS SOALAN TAMAT

Page 3 of 3

You might also like