Professional Documents
Culture Documents
Sample MCQ CBCP2202
Sample MCQ CBCP2202
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
C. Skip the test of the statements of the loop in the current iteration.
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
A. read
B. fscanf
C. readln
A. read
B. fscanf
C. readln
Page 3 of 3