77 EXAMPLES & EXERCISES OF C PROGRAMMING 95
48. Which of the following identifiers is INVALID?
i. integer
ii. printf
iii. Net-total
iv. _sum
A. i, ii and iii
B. i, iii, and iv
C. ii and iii
D. i, ii, iii, iv
49. Which of the following is a selection statement?
A. switch case
B. while
C. do while
D. for
50. Does the following flowchart represent which control structure in C?
A. if else selection structure
B. switch case selection structure
C. while repetition structure
D. for repetition structure
51. Which of the following statements best describes 'Pseudocode'?
A. A graphical depiction of data, information, and workflow that details problem-
solving steps by connecting specific symbols to flow lines.
B. Defined as a numbered list of instructions to perform some task usually used to
outline the general steps in an algorithm without having to write actual code.
C. Before the actual programme development, a list of measures to address problems
is established to ensure that the right problem-solving technique is used.
D. It lists the inputs, the outputs, and the procedures that must be taken to convert the
inputs into the outputs of a programme.
77 EXAMPLES & EXERCISES OF C PROGRAMMING 96
52. Which of the statements below, best describes a ‘Flow Chart’?
A. A graphical representation of data, information, and workflow using certain symbols
that are connected to flow lines to describe the instructions carried out in problem
solving.
B. It is simply a numbered list of instructions to perform some task, usually used to
outline the general steps in an algorithm, without having to write actual code.
C. A list of measures to solve problems is created before the actual program code to
make sure the correct problem solution method is used.
D. Identify the program’s inputs, its outputs, and the processing steps that required
transforming the inputs into outputs.
53. X is best described as a / an …………………………
X is a memory location in a computer’s memory to store varied value data.
To indicate the memory location, each X should be given a unique name.
X is the symbol that represents a memory location.
A. Operator
B. Constant
C. Variable
D. Data type
54. To print out a and b below, which of the following printf() statement should be used?
#include <stdio.h>
void main ()
{
float a=3.14;
unsigned char b=’&’;
}
A. printf (“ %f %d”, a, b);
B. printf (“ %f %x”, a, b);
C. printf (“ %f %s”, a, b);
D. printf (“ %f %c”, a, b);
77 EXAMPLES & EXERCISES OF C PROGRAMMING 97
55. What is the output of the programme based on the flowchart below?
Start
Insert grade =50
If intGrade >= 70 No Message to print:
“Failing grade”
Yes
Message to print:
“Passing grade”
Stop
A. Message to print: “Failing grade.”
B. Message to print: “Passing grade.”
C. Failing grade.
D. Passing grade.
56. In the documentation of a programming project, a programmer needs to determine the
functions, variables, and formulas that he should use. This statement refers to:
A. Determining requirement specification process
B. Writing project proposal, flowchart, and project plan process
C. Making specification test process
D. Writing source code process
57. Compiler generates ______________ file.
A. Executable code
B. Object code
C. Assembly code
D. None of the above
58. How many different outcomes can be achieved with a single if-else statement?
A. 1
B. 2
C. 3
D. 4
77 EXAMPLES & EXERCISES OF C PROGRAMMING 98
59. The infinite looping CANNOT be avoided by a _______________ if the condition is missing in
a ‘for’ loop.
A. continue statement
B. go to statement
C. return statement
D. break statement
60. Which of the following statements are TRUE about while loop statements?
i. It is also known as exit controlled loop.
ii. It is an entry-controlled loop.
iii. The body of loop will be executed at least once even if the test condition is false.
iv. If test condition is initially false the body of loop is not executed at all.
A. i and iii
B. i and iv
C. ii and iii
D. ii and iv
61. An example of a C programme would be?
A. Variables
B. Statements
C. Functions
D. All of the above
62. Name the flowchart symbol below.
A. Terminal
B. On-page connector
C. Subroutine
D. Off-page connector
77 EXAMPLES & EXERCISES OF C PROGRAMMING 99
63. What would be the output for the following C code?
#include<stdio.h>
int main()
{
int a=2;
if (a==2)
{
a=-a+2<1;
printf(“%d”,a);
}
else
{
break;
}
}
A. It will print nothing
B. 0
C. -2
D. Compile error
64. Which control structure does the following flowchart represents in C?
A. if
B. if else
C. nested if else
D. switch case
65. What must be done to prevent failing from one case to the next?
A. stop;
B. break;
C. end;
D. A semicolon
77 EXAMPLES & EXERCISES OF C PROGRAMMING 100
66. What does the following code produce?
int x=0;
switch(x)
{
case 1: printf(“One”);break;
case 0: printf(“Zero”); break;
case 2: printf(“Hello World”);break;
}
A. One
B. Zero
C. Hello World
D. ZeroHello World
67. Which of the following is NOT a looping statement?
A. for
B. do while
C. while
D. repeat until
68. The following flowchart represents which control structure in C?
A. if else selection structure
B. switch case selection structure
C. while repetition structure
D. do while repetition structure
69. What is the meaning of the code block while (x>100)?
A. While x is less than one hundred
B. While x is greater than one hundred
C. While x is equal to one hundred
D. While is wishes
77 EXAMPLES & EXERCISES OF C PROGRAMMING 101
70. Imprudent use of goto statement leads to?
A. Unstructured spaghetti code
B. Infinite loop
C. Break statement
D. None of the above
71. What is the final value of x when the code for (int x=0; x<10; x++) is executed?
A. 0
B. 1
C. 9
D. 10
72. What do you think will be the output of the code below?
#include<stdio.h>
void main()
{
int i;
for(i=0;i<10;i++)
printf("%d ",i);
}
A. 0 1 2 3 4 5 6 7 8 9
B. 0 1 2 3 4 5 6 7 8
C. 1 2 3 4 5 6 7 8 9
D. 1 2 3 4 5 6 7 8 9
73. Which of the following statements are TRUE about Do-While loop statements?
i. It is also known as exit controlled loop
ii. It is an entry controlled loop.
iii. The body of loop will be executed at least once even if the test condition is false.
iv. If test condition is initially false the body of loop is not executed at all.
A. i and iii
B. i and iv
C. ii and iii
D. ii and iv
77 EXAMPLES & EXERCISES OF C PROGRAMMING 102
74. In the code below, how many times is the value of x tested?
#include <stdio.h>
int main()
{
int x = 0;
while (x<3)
{
x++;
printf("DEC20012 Is Fun!\n");
}
}
A. 2
B. 4
C. 3
D. 1
75. Choose the value of NUM so that the output would be 6:
#include<stdio.h>
int main()
{
int i;
for(i=6;i>4;i-=2)
{
printf("%d", i);
}
}}
A. 2
B. 4
C. 6
D. 8
76. What does function mean?
A. A function is a collection of statements that carry out a particular activity.
B. Function is the fundamental modular unit. Typically, a function is created to
carry out a specified duty.
C. Function is a block of code that performs a specific task. It is reusable and
has a name.
D. All of the above.
77. Any C program
A. Needs input data
B. Need not contain any function
C. Must contain at least one function
D. None of the above
Answer. 77 EXAMPLES & EXERCISES OF C PROGRAMMING 103
1. C 41. D
2. A 42. C
3. C 43. C
4. B 44. C
5. D 45. C
6. A 46. D
7. A 47. B
8. D 48. C
9. B 49. A
10. B 50. D
11. D 51. B
12. A 52. A
13. C 53. C
14. C 54. D
15. C 55. C
16. B 56. B
17. A 57. B
18. D 58. B
19. C 59. A
20. D 60. D
21. C 61. D
22. B 62. B
23. C 63. D
24. D 64. A
25. D 65. B
26. C 66. B
27. D 67. D
28. B 68. C
29. C 69. A
30. B 70. A
31. C 71. D
32. B 72. A
33. B 73. A
34. B 74. B
35. D 75. C
36. B 76. D
37. C 77. C
38. B
39. C
40. A
77 EXAMPLES & EXERCISES OF C PROGRAMMING
1. Gookin, D. (2013). Beginning Programming with C for Dummies. John Wiley & Sons.
2. Hooi, Y. K. (2018). Fundamentals of Programming Polytechnic Series. Oxford Fajar
Sdn. Bhd.
3. Kanetkar, Y. (2016). Let us C (15th Edition). BPB publications.
4. Klemens, B. (2015). 21st Century C (Second Edition). O'Reilly Published.
5. Kochan, S. G. (2013). Programming in objective-C. Pearson Education India.
6. Learn-c.org. (n.d.). learn-c.org free interactive C tutorial. Retrieved from learn-c.org:
https://www.learn-c.org/
7. Programiz. (n.d.). Parewa Labs Pvt. Ltd. Retrieved from Learn C Programming:
https://www.programiz.com/c-programming
8. Allain, A. (2019). Cprogramming.com. Retrieved from Learn C and C++
Programming: https://www.cprogramming.com/
Page | vi