77 EXAMPLES & EXERCISES OF C PROGRAMMING 45
47 - Reverse_Number.c source code
47 - Reverse_Number.c utput file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 46
48 - Countdown_In_Descending_Order.c source code
48 - Countdown_In_Descending_Order.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 47
49 - Electrical_Power_Calculator.c source code
77 EXAMPLES & EXERCISES OF C PROGRAMMING 48
77 EXAMPLES & EXERCISES OF C PROGRAMMING 49
49 - Electrical_Power_Calculator.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 50
4. ARRAY
50 - 1Array_Initializing.c source code
50 - 1Array_Initializing.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 51
51 - 2Array_with_Loop.c source code
51 - 2Array_with_Loop.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 52
52 - 3Array_Two_Dimentional.c source code
52 - 3Array_Two_Dimentional.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 53
53 - 4Passing_Arrays_as_Function_Arguments.c source code
53 - 4Passing_Arrays_as_Function_Arguments.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 54
54 - 5Array_Find_Average.c source code
54 - 5Array_Find_Average.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 55
55 - 6Array_Find_Total.c source code
55 - 6Array_Find_Total.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 56
56 - 7Array_Total_Daily_Rainfall_For_A_Weeks.c source code
56 - 7Array_Total_Daily_Rainfall_For_A_Weeks.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 57
57 - 8Array_Average_Marks.c source code
57 - 8Array_Average_Marks.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 58
58 - 9Array_Find_Event_Number.c source code
77 EXAMPLES & EXERCISES OF C PROGRAMMING 59
58 - 9Array_Find_Event_Number.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 60
59 - 10Array_Find_Average_For_Two_Dimentional_Marks.c source code
59 - 10Array_Find_Average_For_Two_Dimentional_Marks.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 61
5. FUNCTION.
60 - 1Function_User_Defined.c source code
77 EXAMPLES & EXERCISES OF C PROGRAMMING 62
60 - 1Function_User_Defined.c output file
61 - 2Function_Find_Minimum_Value.c source code
61 - 2Function_Find_Minimum_Value.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 63
62 - 3Function_Call_By_Value.c source code
62 - 3Function_Call_By_Value.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 64
63 - 4Function_Call_By_Reference.c source code
63 - 4Function_Call_By_Reference.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 65
64 - 5Function_Annual_Income.c source code
64 - 5Function_Annual_Income.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 66
65 - 6Function_Calculate Volume For Sphere.c source code
65 - 6Function_Calculate Volume For Sphere.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 67
66 - 7Function_Draw_Face.c source code
77 EXAMPLES & EXERCISES OF C PROGRAMMING 68
66 - 7Function_Draw_Face.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 69
67 - 8Function_Choose_Face_To_Draw.c source code
77 EXAMPLES & EXERCISES OF C PROGRAMMING 70
77 EXAMPLES & EXERCISES OF C PROGRAMMING 71
77 EXAMPLES & EXERCISES OF C PROGRAMMING 72
67 - 8Function_Choose_Face_To_Draw.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 73
68 - 9Function_Draw_House.c source code
77 EXAMPLES & EXERCISES OF C PROGRAMMING 74
68 - 9Function_Draw_House.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 75
69 - 10Function_Pass_by_Value.c source code
69 - 10Function_Pass_by_Value.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 76
70 - 11Function_Sum1.c source code
70 - 11Function_Sum1.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 77
71 - 12Function_Sum2.c source code
71 - 12Function_Sum2.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 78
6. POINTER.
72 - Pointer.c source code
72 - Pointer.c output file
73 - Pointer_AccessThevalueofavariables.c source code
73 - Pointer_AccessThevalueofavariables.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 79
74 - Pointer_ReferenceOperatorandDereferenceOperator.c source code
74 - Pointer_ReferenceOperatorandDereferenceOperator.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 80
7. APPLICATIONS.
75 - Calculate_Paracetamol_Dose.c source code
75 - Calculate_Paracetamol_Dose.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 81
76 - Games_Tic_Tac_Toe.c source code
77 EXAMPLES & EXERCISES OF C PROGRAMMING 82
77 EXAMPLES & EXERCISES OF C PROGRAMMING 83
76 - Games_Tic_Tac_Toe.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 84
77 - Ohms Law Calculator.c source code
77 EXAMPLES & EXERCISES OF C PROGRAMMING 85
77 EXAMPLES & EXERCISES OF C PROGRAMMING 86
77 - Ohms Law Calculator.c output file
77 EXAMPLES & EXERCISES OF C PROGRAMMING 87
77 EXERCISES OF C PROGRAMMING
1. The term 'programming language' is defined as
A. The language which machines communicate with machines
B. The language which machines communicate with humans
C. The language which humans communicate with computers
D. The special language for machines
2. Algorithm is defined as
A. The sequence of steps required to provide a solution to a problem
B. The sequence to provide a solution to a case
C. The instructions to get the output
D. Combined the instructions in a program
3. Alphabetic and numeric combinations, however they must all begin with
an alphabet. Only the underscore (_) may be used as a special character.
This statement is referring to
A. Constants
B. Variables
C. Identifiers
D. Keywords
4. Select the program's output from the following:
#include<stdio.h>
int main()
{
int i=1;
i= 2+2*i++;
printf(“%d”,i);
return 0;
}
A. 3
B. 4
C. 5
D. 6
5. In a "switch-case" statement, which of the following cannot be checked?
A. enum
B. integer
C. character
D. float
77 EXAMPLES & EXERCISES OF C PROGRAMMING 88
6. Daniel wants to design a program to generate the eligible age to apply for a driving license.
Choose the appropriate control structure to solve problem above.
A. if - else
B. switch - case
C. for
D. do - while
7. "Repeat the section of your program based on a specified number of times."
The above statement is referring to
A. for
B. if
C. if - else
D. switch case
8. What will the program's results be?
#include<stdio.h>
int main ()
{
int i=0;
for (i=1; i<=5; i++)
{printf ("%d", i);}
return 0;
}
A. 0 1 2 3 4 5
B. 0 1 2 3 4
C. 1 2 3 4
D. 1 2 3 4 5
9. Identify the elements in planning process.
i. Calculation
ii. Process
iii. Input
iv. Output
v. Progress
A. i, ii, and iii only
B. ii, iii and iv only
C. iii and iv only
D. All of the above.
10. If a is an integer variable, after modulus operation a = 5%2; will return a value
A. 0
B. 1
C. 2
D. 2.5
77 EXAMPLES & EXERCISES OF C PROGRAMMING 89
11. What is the definition of programme?
A. A person, who designs, writes and tests computer programs.
B. A computer tool that allows a programmer to write commands in a format.
C. A translated code that the computer can understand and execute.
D. A specific set of ordered operations for a computer to perform.
12. The programming language structure or grammar refers to the C ____________________.
A. Syntax
B. Grammar
C. Language
D. Semantics
13. C programming is considered a ___________________.
A. Low-Level Language
B. Intermediate Level Language
C. High-Level Language
D. Assembly Language
14. _________________ are closer to human languages and easier to understand. It is also used
to develop complex applications.
A. Machine Language
B. Intermediate Level Language
C. High-Level Language
D. Assembly Language
15. Below are the processes that take place in the pre-processor and compiler during a
compilation process EXCEPT?
A. Replace macro with code
B. Comments removal
C. Generates an executable file
D. Include header file
16. Below are acceptable definitions of a programme EXCEPT?
A. A well-organized set of guidelines that specify to the computer what to do and how
to do it.
B. A numbered list of instructions to perform some task usually used to outline the
general steps in an algorithm without having to write the actual codes.
C. A set of source code written in computer programming language meant for a specific
task and executed in certain sequences.
D. A text file containing sequences of C semantics put together according to C syntax.
77 EXAMPLES & EXERCISES OF C PROGRAMMING 90
17. _________________ contains only numerical information and is difficult to be understood
by a human.
A. Machine Language
B. Intermediate Level Language
C. High-Level Language
D. Assembly Language
18. C programs are converted into machine language with the help of _________________.
A. an interpreter
B. an editor
C. a builder
D. a compiler
19. Which of the following statements BEST describes a programmer?
A. A person who designs computer programs.
B. A person who composes instructions for the computer system.
C. A person who designs, writes, and test computer programs.
D. A person who test computer programs.
20. The vocabulary of commands understood by humans and can be converted into machine
language refers to the C ______________.
A. syntax
B. grammar
C. language
D. Semantics
21. Listed below are the types of programming EXCEPT?
A. Modular programming
B. Structured programing
C. High-Level programming
D. Object-Oriented programming
22. The programming tool uses linked symbols to show the sequence of steps needed to solve a
programming problem.
A. Pseudocode
B. Flowchart
C. Input Process Output (IPO) Table
D. Grid Table
23. Name the flowchart symbol below.
A. Terminal
B. On-page Connector
C. Off-page Connector
D. Subroutine
77 EXAMPLES & EXERCISES OF C PROGRAMMING 91
24. Which of the following descriptions of the algorithm is FALSE?
A. Algorithm must specify a list of steps to be executed in the right order.
B. Algorithm can be represented using a flowchart or pseudocode.
C. Algorithm can be described as a procedure to solve a problem.
D. Algorithm is written only after the coding has been completed.
25. The following pseudocode is an example of a ____________ structure.
START
1. Get Num
2. While(Num>0)
2.1 Sum = Sum + Num
2.2 Num = Num + 1
1. Display Sum
STOP
A. Selection
B. Nested
C. Sequential
D. Looping
26. Does the following flowchart represent which control structure in C programming?
A. if else selection structure
B. switch case selection structure
C. while repetition structure
D. do while repetition structure
27. Which of the following benefits of flowcharting is NOT one?
A. Easier coding
B. Facilitates debugging
C. Effective analysis
D. Improper documentation
77 EXAMPLES & EXERCISES OF C PROGRAMMING 92
28. _______________ is a compact and informal text-based approach to documenting an
algorithm.
A. Histogram
B. Pseudocode
C. Flowchart
D. IPO Chart
29. In a flowchart, the geometrical figure shown below represents.
A. Input and output
B. Subroutine
C. Decisions
D. Process
30. The following pseudocode is an example of a ____________ structure.
START
1. Read A, B
2. Calculate Sum = A + B
3. Display Sum
STOP
A. Selection
B. Sequential
C. Repetition
D. Nested
31. Identify which control structure does the following flowchart represent in C programming?
A. if selection structure
B. switch case selection structure
C. if else selection structure
D. nested if selection structure
32. Which of the following is an advantage of pseudocode?
A. Difficult for beginners to follow the program logic.
B. Facilitates analysis, coding, and debugging processes.
C. No standardized style or format.
D. It does not provide a visual representation of an algorithm.
77 EXAMPLES & EXERCISES OF C PROGRAMMING 93
33. Which of the following is NOT a fundamental C data type?
A. float
B. real
C. int
D. char
34. Which of the following does NOT qualify as a valid bit representation?
A. 8 bit
B. 24 bit
C. 32 bit
D. 64 bit
35. Identify the INCORRECT statement for 'identifier'.
A. An identifier cannot begin with a digit.
B. There cannot be any spaces between the characters in an identifier.
C. Other than underscore, no special symbols may be used.
D. Reserved words can be used as identification.
36. What are the names of the entities whose values can be modified?
A. Tokens
B. Variables
C. Constants
D. Modules
37. If ‘a’ is an integer variable, then a = 5/2; will return a value of?
A. 2.5
B. 0
C. 2
D. 3
38. What should be the appropriate value returned to the operating system when a programme
has successfully run?
A. -1
B. 0
C. 1
D. Programs do not return a value.
39. Which one function is a need for all C programmes?
A. system ()
B. program ()
C. main ()
D. start ()
40. What type of punctuation marks the start and end of a code block?
A. { }
B. ( )
C. [ ]
D. BEGIN and END
77 EXAMPLES & EXERCISES OF C PROGRAMMING 94
41. Every statement in C programming must end with a _________________.
A. period (.)
B. backslash (\)
C. colon (:)
D. semicolon (;)
42. Text enclosed in /* */ in a C program ____________________.
A. gives instructions to the processor
B. declares memory requirements.
C. is ignored by the C compiler.
D. causes a syntax error.
43. Which of the following are INVALID identifiers?
i. R3D3
ii. per-capita
iii. phone#
iv. ice_cream
v. 91_gold
A. i, ii, iv, v
B. i, iv
C. ii, iii, v
D. ii, iv, v
44. What is the correct statement to declare a constant?
A. constant a=10;
B. const int a=10
C. const int a=10;
D. #define a 10;
45. An identifier in C ___________________________.
A. cannot contain any uppercase or lowercase letters, decimal digits, or the underscore
character
B. can have no more than one embedded blank
C. can begin with an underscore
D. can be a reserved word
46. Pick one of the following symbols that can be included in a variable name.
A. asterisk (*)
B. hashtag (#)
C. addition (+)
D. underscore (_)
47. Select the operator with the lowest level of precedence.
A. +
B. =
C. *
D. <