WorksheetsC-Quiz-01
Total questions: 20
Worksheet time: 18mins
Explain what is #include <stdio.h> ?
What is printf for ?
display some message in terminal.
wait for user to reply
exit the program
draw a straight line
what's the result of following code:
printf("Hello Students.\nI am from Nanyang\n");
Hello Students. I am from Nanyang
Hello Students.
I am from Nanyang
Hello Students
I am from Nanyang
Hello Students. I am from Medan
Select which statement that is correct using scanf
scanf("%d", number);
scanf("%d", &number);
scanf("%d %d", &number1, &number2);
scanf("%d %d", number1, number2);
In C, what is the difference between printf() and scanf() functions?
Which of the following is the correct way to read an integer in C?
scanf("%d", num);
scanf("%d", &num);
scanf("%i", num);
scanf(num, "%d");
What is the output of the following code if x = 10?
A
B
AB
No output
If the input given to the following code is 5 10, what will be the output?
5
10
15
510
What happens if we write if (x = 0) instead of if (x == 0)?
It will compare x with 0.
It will cause a compilation error.
It will assign 0 to x, then check the condition.
It will always execute the else part.
What is the output?
Even
7
Odd
No output
What is printed if the input is 4?
Big
Small
4
No output
What is the output?
10
20
Equal
No output
What is the output if input is 6 2?
Divisible
Not Divisible
6 2
No output
What will be printed?
Zero
Non-zero
5
No output
What will be printed?
Yes
No
Compilation error
0
What will be printed?
P
Q
R
No output
What is the output if input is 3 7?
3
4
Equal
7
If input is 7, what is printed?
A
B
C
D
What will be printed?
True
False
5
Compilation error
The program below is supposed to:
Ask the user for a number.
Divide the number by 2.
Print the result.
But it contains syntax errors and a logic error.
Fix and write the correct one and also explain what's the error!
