Unit 1: Introduction to Programming - Practice Quiz

CAP1008 — C Programming 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is a computer program?

introduction to programming Easy
A. A type of computer memory
B. A set of instructions written to perform a specific task
C. An electronic circuit inside the CPU
D. A physical component of the computer

2 The process of writing a set of instructions for a computer is called:

introduction to programming Easy
A. Debugging
B. Programming
C. Compiling
D. Formatting

3 A person who writes computer programs is called a:

program concept Easy
A. Programmer
B. Analyst
C. Operator
D. Designer

4 Which of the following best describes source code?

program concept Easy
A. The hardware that runs the program
B. The electricity supplied to the machine
C. The human-readable instructions written by a programmer in a programming language
D. The final output shown to the user

5 Which of the following is a desirable characteristic of a good program?

characteristics of programming Easy
A. Complexity
B. Ambiguity
C. Reliability
D. Slowness

6 A program that is easy to read, understand, and modify is said to have good:

characteristics of programming Easy
A. Obscurity
B. Redundancy
C. Volatility
D. Maintainability

7 The ability of a program to run on different types of machines with little or no change is called:

characteristics of programming Easy
A. Security
B. Accuracy
C. Portability
D. Efficiency

8 Which stage usually comes first in program development?

stages in program development Easy
A. Problem definition and analysis
B. Documentation
C. Coding the program
D. Testing the program

9 The process of finding and correcting errors in a program is known as:

stages in program development Easy
A. Executing
B. Compiling
C. Linking
D. Debugging

10 What is an algorithm?

algorithms Easy
A. A software error
B. A step-by-step procedure to solve a problem
C. A type of computer hardware
D. A programming language

11 Which property must every algorithm have?

algorithms Easy
A. It must use graphics
B. It must run forever without stopping
C. It must terminate after a finite number of steps
D. It must be written only in C language

12 Each step of an algorithm should be:

algorithms Easy
A. Written in binary only
B. Optional to follow
C. Clear and unambiguous
D. Confusing and vague

13 Pseudocode is best described as:

notations Easy
A. A special hardware notation
B. A compiled binary file
C. The actual machine code executed by the CPU
D. An informal, language-like way of describing an algorithm

14 Which notation uses plain English-like statements rather than a specific programming language syntax?

notations Easy
A. Binary code
B. Pseudocode
C. Machine code
D. Assembly code

15 A flowchart is a:

flowchart Easy
A. Graphical representation of an algorithm
B. Programming language
C. Type of computer virus
D. Storage device

16 In a flowchart, which symbol is used to represent a decision?

flowchart Easy
A. Parallelogram
B. Rectangle
C. Diamond
D. Oval

17 Which flowchart symbol represents the start or end of a process?

flowchart Easy
A. Rectangle
B. Oval (terminal)
C. Diamond
D. Arrow

18 Which of the following is a programming methodology?

types of programming methodologies Easy
A. Random programming
B. Invisible programming
C. Circular programming
D. Structured programming

19 In the top-down approach, a large problem is:

top down and bottom up program development cycle with case study Easy
A. Combined into one huge module
B. Broken down into smaller sub-problems
C. Solved only in machine code
D. Ignored until the end

20 The bottom-up approach to program development begins by:

top down and bottom up program development cycle with case study Easy
A. Deleting all sub-modules
B. Writing documentation before analysis
C. Building smaller components first and then combining them into a complete system
D. Designing the main module last

21 A team is converting a real-world payroll process into a computer program. Which sequence correctly represents the transformation from problem to executable software?

introduction to programming Medium
A. Algorithm → Problem → Machine code → Program
B. Program → Algorithm → Problem → Machine code
C. Problem → Algorithm → Program → Machine code
D. Machine code → Program → Algorithm → Problem

22 A program repeatedly produces different results for the same input values even though the code is unchanged. Which fundamental property of a correct program is being violated?

program concept Medium
A. Modularity
B. Determinism
C. Readability
D. Portability

23 A developer rewrites a long function into several smaller, self-contained functions. Which programming characteristic is most directly improved?

characteristics of programming Medium
A. Determinism
B. Finiteness
C. Modularity
D. Efficiency

24 Two programs solve the same task, but Program A runs in time while Program B runs in time. Which characteristic distinguishes Program A as the better choice for large inputs?

characteristics of programming Medium
A. Readability
B. Efficiency
C. Reliability
D. Portability

25 During program development, a compiler reports that a semicolon is missing. At which stage is this error detected?

stages in program development Medium
A. Design stage
B. Compilation stage
C. Requirement analysis stage
D. Maintenance stage

26 A program compiles and runs, but gives wrong output because a formula was written incorrectly. This is best classified as which type of error, and it is handled in which stage?

stages in program development Medium
A. Linker error, compilation stage
B. Syntax error, coding stage
C. Logical error, testing/debugging stage
D. Runtime crash, design stage

27 Which ordering of program development stages is correct?

stages in program development Medium
A. Design → Coding → Problem analysis → Maintenance → Testing
B. Coding → Problem analysis → Testing → Design → Maintenance
C. Problem analysis → Design → Coding → Testing → Maintenance
D. Testing → Coding → Design → Problem analysis → Maintenance

28 Consider this algorithm step: while (i > 0) { print i; } where i is never changed inside the loop. Which essential property of an algorithm does this violate?

algorithms Medium
A. Finiteness
B. Input
C. Definiteness
D. Output

29 An algorithm contains the instruction "add a suitable number to " without specifying which number. Which property of a good algorithm is missing?

algorithms Medium
A. Output
B. Definiteness
C. Effectiveness
D. Finiteness

30 Given the algorithm: sum = 0; for i = 1 to 4: sum = sum + i, what is the final value of sum?

algorithms Medium
A.
B.
C.
D.

31 Which of the following expressions is written in postfix (Reverse Polish) notation for the infix expression ?

notations Medium
A.
B.
C.
D.

32 The prefix notation of an expression is . Which infix expression does it represent?

notations Medium
A.
B.
C.
D.

33 While drawing a flowchart, which symbol should be used to represent a decision such as if x > 0?

flowchart Medium
A. Oval (ellipse)
B. Diamond (rhombus)
C. Parallelogram
D. Rectangle

34 In a flowchart, the parallelogram symbol is used to represent which operation?

flowchart Medium
A. Input or output
B. A decision
C. A processing step
D. The start or end

35 A flowchart contains many arrows crossing back to earlier steps, forming complex loops in a large program. Which limitation of flowcharts does this illustrate?

flowchart Medium
A. They become hard to modify and manage as complexity grows
B. They cannot show any loops
C. They cannot represent decisions
D. They execute faster than code

36 A methodology that organizes software around objects containing both data and the functions that operate on them is called:

types of programming methodologies Medium
A. Procedural programming
B. Object-oriented programming
C. Unstructured programming
D. Machine-level programming

37 A programmer avoids goto statements and builds a program using only sequence, selection, and iteration constructs. Which methodology is being followed?

types of programming methodologies Medium
A. Structured programming
B. Object-oriented programming
C. Logic programming
D. Event-driven programming

38 A design team first builds and tests small utility functions, then combines them into larger modules to form the final system. Which approach is this?

top down and bottom up program development Medium
A. Top-down approach
B. Bottom-up approach
C. Event-driven design
D. Waterfall analysis

39 In a top-down design of a billing system, the main problem is split into "read data", "calculate bill", and "print bill". This process of dividing a problem into smaller subproblems is called:

top down and bottom up program development Medium
A. Encapsulation
B. Overloading
C. Stepwise refinement
D. Linking

40 In a case study, a team must build a large system reusing many existing tested library components. Which development approach is generally most suitable?

top down and bottom up program development Medium
A. Top-down, because it builds small parts first
B. Bottom-up, because existing components are combined into the whole
C. Top-down, because it ignores existing components
D. Bottom-up, because it starts from the main module

41 Consider the algorithm:

set x = 0
for i from 1 to n:
for j from i to n:
x = x + 1

What is the final value of as a closed-form expression in ?

algorithms Hard
A.
B.
C.
D.

42 An algorithm must be finite, definite, effective, and have input/output. Which scenario violates the property of definiteness specifically?

algorithms Hard
A. A loop never terminates for certain inputs
B. A step says "choose a suitable value for x" without specifying how
C. A step requires computing over reals
D. The algorithm produces no output at all

43 In a flowchart, a program reads , then while replaces with if even, else , counting iterations. For , how many iterations occur before becomes ?

flowchart Hard
A. 6
B. 9
C. 8
D. 7

44 A team builds a payroll system by first coding and unit-testing utility routines (tax calc, date math), then combining them into modules, and finally into the full application. Which methodology and integration strategy does this reflect?

top down and bottom up program development cycle with case study Hard
A. Bottom-up development with bottom-up integration testing
B. Bottom-up development with big-bang integration
C. Top-down development with driver-based integration
D. Top-down development with stub-based integration

45 Which statement most accurately distinguishes procedural from structured programming?

types of programming methodologies Hard
A. Procedural programming forbids loops whereas structured programming requires them
B. Structured programming restricts control flow to sequence, selection, and iteration, avoiding arbitrary jumps, while procedural programming organizes code into procedures/functions
C. They are identical terms with no distinction in any context
D. Structured programming forbids the use of functions entirely

46 During which stage is the root cause of a logical error (correct compilation but wrong output) most appropriately identified and corrected?

stages in program development Hard
A. Testing and debugging
B. Coding
C. Documentation
D. Problem analysis

47 Two algorithms solve the same problem: A runs in and B runs in . For which range of input sizes is algorithm B strictly faster than A?

algorithms Hard
A.
B.
C.
D.

48 Why can an unstructured flowchart containing arbitrary crossing flow lines and multiple entry points into a loop be problematic when translated to structured code?

flowchart Hard
A. Flowcharts can never be converted into any programming language
B. It guarantees an infinite loop in every case
C. It may require goto or duplicated logic because it cannot map cleanly onto sequence/selection/iteration constructs
D. It always doubles the program's memory usage

49 A program computes correct results but its runtime doubles each time input size increases by one element. Which quality characteristic is most severely compromised?

characteristics of programming Hard
A. Readability
B. Correctness
C. Portability
D. Efficiency

50 Convert the infix expression to postfix notation, respecting standard operator precedence and left-to-right associativity.

notations Hard
A.
B.
C.
D.

51 In top-down development of a large system, why are stubs used during early integration testing?

top down and bottom up program development cycle with case study Hard
A. To replace the main module with a dummy so nothing runs
B. To permanently remove untested functions from the build
C. To convert the program from procedural to object-oriented style
D. To simulate lower-level modules that are not yet implemented, so higher-level logic can be tested

52 Consider this algorithm on integer :

c = 0
while n > 0:
n = n & (n - 1)
c = c + 1

What does represent when the loop ends?

algorithms Hard
A.
B. The number of digits in
C. The number of trailing zeros in
D. The number of 1-bits (set bits) in the binary representation of

53 A completed program passes all developer tests but frequently breaks after client-side changes over the years. Which stage of the program development life cycle is most directly involved in addressing this ongoing situation?

stages in program development Hard
A. Design
B. Coding
C. Maintenance
D. Testing

54 Evaluate the postfix expression 5 1 2 + 4 * + 3 - using a stack. What is the result?

notations Hard
A. 14
B. 12
C. 10
D. 16

55 Which statement best explains why a high-level language program cannot be executed directly by the CPU without a translator?

introduction to programming Hard
A. The CPU only executes machine code (binary instructions), so source code must be compiled or interpreted first
B. High-level programs are always larger than RAM capacity
C. High-level languages contain too many comments for the CPU
D. The CPU lacks enough registers to store variable names

56 A student claims: "A program and an algorithm are exactly the same thing." What is the most accurate correction?

program concept Hard
A. A program is language-independent while an algorithm is language-specific
B. There is no difference; the terms are fully interchangeable
C. An algorithm must always be longer than the equivalent program
D. An algorithm is a language-independent finite procedure; a program is its concrete implementation in a specific programming language

57 A flowchart uses a diamond symbol with one entry and two exits labeled True/False. Which fundamental structured-programming construct does this represent, and what is the risk if one exit path is left unconnected?

flowchart Hard
A. Input/output; an unconnected exit prints garbage
B. Sequence; an unconnected exit has no effect
C. Selection (decision); an unconnected exit causes undefined/incomplete control flow
D. Iteration; an unconnected exit merely slows execution

58 Two correct programs solve the same task. Program X uses cryptic single-letter names and no comments; Program Y is well-structured and documented. Both run identically fast. Which characteristic most justifies preferring Y in a long-lived project?

characteristics of programming Hard
A. Correctness
B. Reliability
C. Maintainability
D. Efficiency

59 Which combination of features uniquely characterizes the object-oriented methodology as opposed to purely structured/procedural approaches?

types of programming methodologies Hard
A. Exclusive use of goto for control transfer
B. Decomposition of a task into standalone functions only
C. Encapsulation, inheritance, and polymorphism organized around objects
D. Only sequence, selection, and iteration constructs

60 For an ATM software case study, module reuse across many banks is a top priority and the low-level transaction primitives are well understood. Which development approach is most advantageous, and why?

top down and bottom up program development cycle with case study Hard
A. Bottom-up, because it eliminates the need for any design phase
B. Bottom-up, because reusable, well-tested low-level modules are built first and combined into varied higher systems
C. Top-down, because low-level modules are irrelevant to reuse
D. Top-down, because it forbids code reuse entirely