Programming Fundamentals – 300 MCQs

Programming Fundamentals – 300 MCQs

Programming Fundamentals – 300 MCQs

Course-Aligned Multiple Choice Questions for Exam Preparation

Problem Solving, Programming Basics, Conditions, Loops, Arrays, Functions, Strings, Memory and File I/O

300 MCQs6 Sections4 (3-3) Credit HoursInteractive HTML
300
Total MCQs
6
Sections
PF
Course
4 (3-3)
Credit Hours
SECTION 1: Problem Solving, Algorithms and Architecture (Q1-Q50)
Q1

The first step in solving a programming problem is to:

  • AWrite code immediately
  • BUnderstand and define the problem
  • CChoose a compiler
  • DRun test cases
Q2

An algorithm is best described as:

  • AA programming language
  • BA step-by-step solution to a problem
  • CA hardware device
  • DA type of variable
Q3

Which feature is essential for a good algorithm?

  • AAmbiguity
  • BFiniteness
  • CUnlimited steps
  • DDependence on one language
Q4

Pseudocode is mainly used to:

  • ACompile programs
  • BRepresent logic in human-readable form
  • CStore data permanently
  • DReplace hardware
Q5

A flowchart uses diamonds to represent:

  • AInput/Output
  • BDecision points
  • CProcessing steps
  • DProgram start
Q6

A rectangle in a flowchart usually represents:

  • ADecision
  • BInput/Output
  • CProcess
  • DConnector
Q7

The oval symbol in a flowchart commonly represents:

  • ALoop body
  • BStart or End
  • CArithmetic operation
  • DVariable declaration
Q8

Breaking a large problem into smaller subproblems is called:

  • ACompilation
  • BDecomposition
  • CLinking
  • DAllocation
Q9

In top-down design, developers usually start with:

  • ADetailed syntax
  • BThe overall problem and major tasks
  • CMachine code
  • DMemory addresses
Q10

A test case is used to:

  • ADecorate code
  • BVerify program correctness
  • CCompile faster
  • DIncrease RAM
Q11

Dry run means:

  • ADeleting code
  • BTracing a program manually with sample input
  • CCompiling without errors
  • DUsing no variables
Q12

An input to a program is:

  • AThe information supplied to be processed
  • BAlways a number
  • CThe final answer
  • DOnly keyboard text
Q13

The result produced by a program is called:

  • AInput
  • BOutput
  • CComment
  • DOperand
Q14

Which is a valid characteristic of problem-solving logic?

  • AIgnore constraints
  • BIdentify inputs, processing, and outputs
  • CAvoid planning
  • DRemove testing
Q15

The IPO model stands for:

  • AInput, Process, Output
  • BInteger, Pointer, Object
  • CInput, Print, Option
  • DInstruction, Processor, Output
Q16

An algorithm should produce the same correct result for the same valid input, which shows:

  • ARandomness
  • BDeterminism
  • CSyntax error
  • DMemory leak
Q17

The Von Neumann architecture stores instructions and data in:

  • ADifferent permanent devices only
  • BThe same memory
  • CRegisters only
  • DThe compiler
Q18

Which unit performs arithmetic and logical operations in a computer?

  • AALU
  • BHard disk
  • CCompiler
  • DLinker
Q19

The control unit mainly:

  • AStores files
  • BDirects and coordinates operations
  • CPrints results
  • DCreates source code
Q20

Main memory in Von Neumann architecture is used to store:

  • AOnly output
  • BPrograms and data currently in use
  • COnly machine code backups
  • DInternet settings
Q21

Which of the following is an input device?

  • AMonitor
  • BPrinter
  • CKeyboard
  • DSpeaker
Q22

The CPU is primarily made up of:

  • AALU and Control Unit
  • BCompiler and linker
  • CMouse and keyboard
  • DRAM and ROM
Q23

A compiler translates:

  • AMachine code to English
  • BHigh-level source code to machine/object code
  • CInput to output
  • DFlowcharts to images
Q24

A linker is responsible for:

  • AExecuting code line by line
  • BCombining object files and libraries into an executable
  • CDesigning algorithms
  • DAllocating keyboard input
Q25

A syntax error is usually detected by the:

  • APower supply
  • BCompiler or interpreter
  • CMonitor
  • DOperating system clock
Q26

A logic error means the program:

  • ACannot be saved
  • BRuns but gives incorrect results
  • CCannot be compiled due to spelling mistake
  • DHas no variables
Q27

A runtime error occurs:

  • ADuring manual dry run only
  • BWhile the program is executing
  • CBefore writing code
  • DDuring printing of source code
Q28

Which tool typically translates and runs one statement at a time?

  • AInterpreter
  • BKeyboard
  • CScanner
  • DALU
Q29

Source code is written by programmers in:

  • ABinary only
  • BA high-level language
  • CMachine microcode only
  • DHexadecimal only
Q30

Object code is:

  • AHuman language steps
  • BTranslated low-level code produced before final executable
  • CA comment block
  • DAn algorithm
Q31

The purpose of comments in a program is to:

  • AChange variable values
  • BExplain code to humans
  • CSpeed up execution
  • DReplace functions
Q32

Which of the following is not part of basic problem analysis?

  • ARequired output
  • BAvailable input
  • CProcessing needed
  • DBrand of monitor
Q33

Trace tables are useful for:

  • ADecorating reports
  • BFollowing variable values step by step
  • CStoring files
  • DCompiling libraries
Q34

The sequence structure in programming means:

  • AStatements execute one after another
  • BOnly decisions are used
  • COnly loops are used
  • DCode never ends
Q35

Selection structure is used when:

  • AThe program always follows one path
  • BA decision chooses among alternatives
  • CNo comparison is needed
  • DOnly arrays are present
Q36

Iteration structure means:

  • AStopping immediately
  • BRepeating a block of statements
  • CUsing only functions
  • DAvoiding conditions
Q37

A well-defined algorithm must have:

  • AInfinite steps
  • BClear and unambiguous instructions
  • COnly numeric input
  • DNo output
Q38

Refining an algorithm into more detail is called:

  • AStepwise refinement
  • BLinking
  • CCasting
  • DEncryption
Q39

Which is the best reason to design before coding?

  • ATo avoid testing
  • BTo make logic clearer and reduce mistakes
  • CTo use more memory
  • DTo eliminate output
Q40

A variable appearing in an algorithm before coding usually represents:

  • AA fixed symbol with no value
  • BA named storage location for changing data
  • CA hardware wire
  • DAn error message
Q41

The basic fetch-decode-execute cycle is performed by the:

  • ACPU
  • BPrinter
  • CScanner
  • DCompiler
Q42

Which statement about high-level languages is true?

  • AThey are closer to human thinking than machine code
  • BThey cannot perform arithmetic
  • CThey do not need translators
  • DThey are only for web pages
Q43

In problem solving, constraints are:

  • AConditions or limits the solution must satisfy
  • BComments in code
  • COnly output values
  • DThe same as variables
Q44

Which one is an example of an algorithmic step?

  • AUse a blue screen
  • BRead two numbers and add them
  • CInstall more RAM
  • DChange the keyboard
Q45

A program is:

  • AAlways a flowchart
  • BAn implementation of an algorithm in a programming language
  • CA hardware port
  • DA memory chip
Q46

Which testing approach uses normal, boundary, and invalid inputs?

  • ABlack-box style test design
  • BOnly syntax testing
  • COnly hardware checking
  • DNo-input testing
Q47

The linker usually works after the:

  • AKeyboard
  • BCompiler
  • CMonitor
  • DMouse
Q48

A machine instruction is directly understood by the:

  • ACPU
  • BProgrammer only
  • CFlowchart
  • DCompiler comments
Q49

Abstraction in problem solving helps by:

  • AHiding irrelevant details and focusing on essentials
  • BAdding syntax errors
  • CRemoving all variables
  • DAvoiding functions
Q50

A correct algorithm must terminate after:

  • AZero or more well-defined finite steps
  • BInfinite iterations
  • COnly one step
  • DCompilation
SECTION 2: Programming Basics, Data Types and Operators (Q51-Q100)
Q51

A variable is:

  • AA fixed value that never changes
  • BA named memory location whose value may change
  • CA compiler message
  • DA hardware unit
Q52

A constant is:

  • AA value that does not change during program execution
  • BAlways stored in a file
  • CThe same as a variable
  • DA loop statement
Q53

Which of the following is a valid reason to use meaningful variable names?

  • ATo confuse other programmers
  • BTo improve readability and maintenance
  • CTo increase CPU speed directly
  • DTo avoid all runtime errors
Q54

An integer data type is generally used to store:

  • AWhole numbers
  • BOnly characters
  • COnly decimal fractions
  • DFile names
Q55

A floating-point data type is commonly used for:

  • AWhole numbers only
  • BNumbers with fractional parts
  • CSingle characters only
  • DBoolean values only
Q56

A character data type usually stores:

  • AA full paragraph
  • BOne symbol such as a letter or digit
  • CAn array of numbers
  • DA function
Q57

A Boolean type usually has values:

  • A0 to 9
  • BTrue and False
  • CA to Z
  • DSmall and large
Q58

Declaring a variable means:

  • AAssigning a random value
  • BSpecifying its name and type before use
  • CPrinting it
  • DDeleting it
Q59

Initialization means:

  • AUsing a variable in a loop
  • BGiving a variable an initial value
  • CChanging its type
  • DMoving it to a file
Q60

Which operator is commonly used for assignment?

  • A==
  • B=
  • C!=
  • D<=
Q61

The expression a + b uses + as a(n):

  • ARelational operator
  • BArithmetic operator
  • CLogical operator
  • DBitwise-only symbol
Q62

Which operator gives the remainder after division?

  • A/
  • B%
  • C*
  • D+
Q63

If x = 7 and y = 2, the value of x / y in integer division is often:

  • A3
  • B3.5
  • C4
  • D2
Q64

Which operator is used to compare equality?

  • A=
  • B==
  • C+
  • D&&
Q65

The expression x > y uses > as a:

  • AAssignment operator
  • BComparison operator
  • CString operator
  • DFile operator
Q66

Logical AND is true when:

  • AAt least one condition is true
  • BBoth conditions are true
  • CBoth are false
  • DThe first is false
Q67

Logical OR is false when:

  • AAt least one condition is true
  • BBoth conditions are false
  • CBoth conditions are true
  • DThe first is true
Q68

Logical NOT does what?

  • AAdds two values
  • BReverses a Boolean condition
  • CStores data in memory
  • DReads input
Q69

Operator precedence determines:

  • AThe order in which operations are evaluated
  • BThe size of variables
  • CThe speed of the linker
  • DThe file extension
Q70

Parentheses in expressions are useful because they:

  • AAlways slow down a program
  • BMake evaluation order explicit
  • CConvert integers to strings automatically
  • DRemove syntax errors
Q71

An expression is:

  • AA combination of values, variables, and operators that produces a result
  • BOnly a comment
  • CA file handle
  • DA hardware register
Q72

The value entered by a user at runtime is usually stored in a:

  • AComment
  • BVariable
  • CCompiler
  • DAlgorithm
Q73

Type conversion means:

  • ADeleting a type
  • BChanging data from one type to another
  • CReading from a file
  • DUsing only integers
Q74

Implicit type conversion is:

  • ADone automatically by the language in some cases
  • BAlways done by the user manually
  • CIllegal in every language
  • DOnly for strings
Q75

Explicit type conversion is often called:

  • ALooping
  • BCasting
  • CLinking
  • DTracing
Q76

Overflow occurs when:

  • AA result is too large for the data type
  • BInput is too small
  • CA comment is too long
  • DA file is empty
Q77

Underflow commonly refers to:

  • AA value becoming too small in magnitude for the representation
  • BA syntax mistake
  • CUsing too many variables
  • DA missing semicolon
Q78

Which of these is a unary operator?

  • A– used to negate a value
  • B+ used between two variables
  • C* used to multiply
  • D/ used to divide
Q79

Incrementing a variable means:

  • ADecreasing it by 1
  • BIncreasing it, often by 1
  • CChanging its type
  • DPrinting it
Q80

Decrementing a variable means:

  • AIncreasing it by 1
  • BReducing it, often by 1
  • CCopying it to a file
  • DDeclaring it
Q81

Which statement about identifiers is true?

  • AThey should be meaningful and follow language rules
  • BThey can contain spaces in all languages
  • CThey must begin with a digit
  • DThey are the same as keywords
Q82

A reserved keyword is:

  • AA user-defined variable
  • BA word with special meaning in the language
  • CA random comment
  • DA file path
Q83

Input statements are used to:

  • AGet data into a program
  • BCreate loops only
  • CCompare two values
  • DTranslate code
Q84

Output statements are used to:

  • ADisplay results or messages
  • BAllocate memory only
  • CCreate compilers
  • DRead keyboard drivers
Q85

Concatenation in output often means:

  • AJoining values or strings together
  • BDividing integers
  • CNegating a Boolean
  • DAllocating arrays
Q86

A newline in output is useful for:

  • AFormatting displayed text on separate lines
  • BChanging variable type
  • CEnding program translation
  • DCreating pointers
Q87

Which of the following is a relational operator?

  • A<=
  • B&&
  • C%
  • D=
Q88

Which of the following is a logical operator?

  • A+
  • B||
  • C/
  • D<
Q89

The result of a comparison expression is usually:

  • AA character
  • BA Boolean value
  • CA file
  • DA compiler
Q90

Short-circuit evaluation in logical expressions means:

  • ABoth sides are always evaluated
  • BEvaluation may stop early when result is already known
  • COnly arithmetic is allowed
  • DStrings are ignored
Q91

An lvalue generally refers to:

  • AA location that can appear on the left side of assignment
  • BAny comment
  • COnly constants
  • DOnly output
Q92

A literal is:

  • AA named variable
  • BA fixed value written directly in code
  • CA function call
  • DA loop block
Q93

Which of the following is a numeric literal?

  • A"Hello"
  • B3.14
  • Ctrue
  • D'A'
Q94

A string literal is typically enclosed in:

  • ADouble quotes
  • BCurly braces
  • CAngle brackets
  • DNo symbols
Q95

Reading input without validating it can cause:

  • ANo possible issues
  • BIncorrect processing or runtime problems
  • CFaster execution always
  • DAutomatic file creation
Q96

Which choice best describes debugging?

  • AFinding and fixing errors in a program
  • BOnly designing flowcharts
  • COnly compiling code
  • DOnly writing comments
Q97

A semicolon or similar terminator missing in some languages often causes:

  • ALogic error only
  • BSyntax error
  • COverflow
  • DDynamic allocation
Q98

The expression 5 < 8 && 2 < 1 evaluates to:

  • ATrue
  • BFalse
  • C10
  • DUndefined in all languages
Q99

If a = 5, then a += 3 usually means:

  • Aa becomes 8
  • Ba becomes 15
  • Ca becomes 2
  • Da stays 5
Q100

The main purpose of data types is to:

  • AConfuse the compiler
  • BDefine kind of data and operations allowed
  • CAvoid all bugs automatically
  • DStore comments
SECTION 3: Conditional Statements and Execution Flow (Q101-Q150)
Q101

A conditional statement is used to:

  • ARepeat code forever
  • BMake decisions based on conditions
  • CStore files
  • DDeclare all variables
Q102

The simplest selection structure checks:

  • AOne condition
  • BOnly arithmetic
  • COnly strings
  • DNo variables
Q103

An if statement executes its block when the condition is:

  • AFalse
  • BTrue
  • CA character
  • DA file
Q104

An if-else statement provides:

  • AOnly one possible path
  • BTwo alternative paths
  • CA loop only
  • DMemory allocation
Q105

An else-if ladder is useful when:

  • AOnly one comparison is needed
  • BMultiple conditions must be checked in sequence
  • CNo decisions are required
  • DOnly arrays are used
Q106

Nested if statements mean:

  • ADecisions placed inside other decisions
  • BLoops inside arrays
  • CStrings inside files
  • DComments inside variables
Q107

The condition in a selection statement should evaluate to:

  • AA Boolean value
  • BAlways a string
  • CAlways an integer array
  • DAn executable file
Q108

Which operator checks whether two values are not equal?

  • A=
  • B!=
  • C<
  • D&&
Q109

A compound condition combines simpler conditions using:

  • AArithmetic operators only
  • BLogical operators
  • CFile operators
  • DPointer operators only
Q110

Which statement is true about if-else chains?

  • AAll branches execute together
  • BAt most one matching branch executes in a standard ladder
  • CThe else branch always runs first
  • DThey cannot use comparisons
Q111

The dangling else problem is related to:

  • AFile opening
  • BAmbiguity of which if an else belongs to
  • CArray indexing
  • DDynamic memory
Q112

A switch-style statement is most suitable when:

  • ATesting many exact discrete values of one expression
  • BUsing floating point in all cases
  • CReading files
  • DAllocating memory
Q113

A switch/case statement commonly uses:

  • AOnly relational ranges
  • BCase labels and optional default
  • CPointers only
  • DNested functions only
Q114

The default branch in a switch usually executes when:

  • AThe first case matches
  • BNo case matches
  • CEvery case matches
  • DThe compiler fails
Q115

Break in a switch often prevents:

  • AInput reading
  • BFall-through to the next case
  • CVariable declaration
  • DFunction calls
Q116

Fall-through in a switch means:

  • AControl jumps to main memory
  • BExecution continues into the next case if not stopped
  • CA variable becomes false
  • DA file closes automatically
Q117

Which of the following is a valid use of decision making?

  • AChoosing grade based on marks
  • BDeclaring a constant
  • CCreating an executable
  • DFormatting a disk
Q118

A relational expression such as x >= 10 is often used as:

  • AA file name
  • BA condition
  • CA comment
  • DA string literal
Q119

In many languages, 0 in a condition is treated as:

  • ATrue
  • BFalse
  • CAlways invalid
  • DA pointer
Q120

An if block with no braces in some languages typically controls:

  • AOnly the next statement
  • BThe whole file
  • CEvery later line
  • DA function
Q121

A common reason to use braces even for one statement is to:

  • AReduce readability
  • BAvoid mistakes during later modification
  • CSlow execution
  • DChange data type
Q122

Which is an example of a mutually exclusive decision set?

  • APositive, negative, or zero for one number
  • BReading and writing the same file
  • CAdding and multiplying at once
  • DUsing two unrelated loops
Q123

The expression !(x < 5) means:

  • Ax is less than 5
  • Bx is not less than 5
  • Cx equals 5 only
  • Dx is always false
Q124

To check whether a number is between 1 and 10 inclusive, a suitable condition is:

  • Ax > 1 || x < 10
  • Bx >= 1 && x <= 10
  • Cx == 1 && x == 10
  • Dx != 1 || x != 10
Q125

Which branch executes if all previous if and else-if conditions are false?

  • Aif branch
  • Belse branch
  • Cswitch branch
  • Dloop body
Q126

A common logic error in conditions is:

  • AUsing assignment instead of equality test
  • BAdding comments
  • CUsing variables
  • DWriting output
Q127

Nested decisions are often used when:

  • AA second decision depends on the first
  • BNo condition is required
  • COnly arrays are processed
  • DA file is empty
Q128

Guard conditions are helpful because they:

  • APrevent invalid processing early
  • BAlways allocate memory
  • CReplace functions
  • DCompile faster
Q129

Comparing strings in many languages should be done:

  • AWith an appropriate string comparison method/operator for that language
  • BAlways with pointer addresses
  • COnly by length
  • DNever inside conditions
Q130

A menu-driven program often uses:

  • ASelection statements
  • BOnly recursion
  • COnly arrays
  • DOnly file I/O
Q131

Boolean variables can improve readability in conditions by:

  • AReplacing all numbers with strings
  • BStoring meaningful true/false results
  • CAvoiding input
  • DEliminating functions
Q132

Which operator has higher precedence in many languages?

  • A&& over ||
  • B|| over &&
  • C= over ==
  • Delse over if
Q133

A ternary conditional operator usually provides:

  • AA compact way to choose between two values
  • BA loop of three steps
  • CFile input
  • DPointer arithmetic only
Q134

The condition x % 2 == 0 checks whether x is:

  • APrime
  • BEven
  • CNegative
  • DA multiple of 3
Q135

When validating user input, conditionals are used to:

  • AIgnore invalid values
  • BAccept or reject based on rules
  • CAllocate arrays automatically
  • DTranslate code
Q136

An example of range checking is:

  • Ax == y
  • Bage >= 0 && age <= 120
  • Cname != name
  • Dscore = 10
Q137

Which is true about indentation?

  • AIt has no value
  • BIt helps humans understand program structure
  • CIt changes arithmetic results
  • DIt replaces syntax
Q138

A switch statement often cannot directly use:

  • AIntegral or discrete values depending on language
  • BCompletely arbitrary code blocks as case labels
  • CCharacters
  • DEnumerated values
Q139

Comparing floating-point values for exact equality can be risky because:

  • AThey cannot be stored
  • BRepresentation errors may occur
  • CThey are always integers
  • DThe compiler forbids it
Q140

A condition is said to be exhaustive when:

  • AEvery meaningful case is covered
  • BOnly the else part exists
  • CNo decisions are used
  • DAll variables are global
Q141

Which construct is most suitable for deciding pass or fail?

  • AIf-else
  • BFile read
  • CPointer dereference
  • DDynamic allocation
Q142

Decision tables can help with:

  • ASystematic design of complex condition combinations
  • BCompiling faster
  • CChanging hardware
  • DStoring arrays
Q143

The statement if (score >= 50) likely means:

  • AThe program stops
  • BA passing threshold is checked
  • CA loop begins
  • DMemory is allocated
Q144

Short-circuit behavior in conditions can help avoid:

  • AReadable code
  • BErrors like division by zero in later terms
  • CUse of functions
  • DString input
Q145

A nested if inside an else branch indicates:

  • AA refined alternative path
  • BA syntax error always
  • CNo condition exists
  • DAn array declaration
Q146

Testing boundary values for conditions means trying:

  • AOnly random inputs
  • BValues at, just below, and just above limits
  • COnly strings
  • DOnly zero
Q147

Which is a practical use of a multi-way decision?

  • AConverting numeric month to month name
  • BAdding two numbers
  • COpening a file
  • DDeclaring variables
Q148

A truth table for a compound condition helps to:

  • AVisualize outcomes for all Boolean input combinations
  • BDraw hardware only
  • CStore source code
  • DReplace testing
Q149

A well-written condition should be:

  • AAmbiguous
  • BClear and as simple as practical
  • CAlways deeply nested
  • DDependent on comments
Q150

Conditional execution changes:

  • AWhich statements run based on current data
  • BThe language syntax
  • CThe processor architecture
  • DThe compiler version
SECTION 4: Loops and Repetition (Q151-Q200)
Q151

A loop is used to:

  • AMake a decision once
  • BRepeat a block of code
  • CStore a string
  • DCompile a file
Q152

A while loop typically repeats while its condition is:

  • AFalse
  • BTrue
  • CA number only
  • DA string only
Q153

A do-while style loop differs from while because it:

  • ANever checks a condition
  • BExecutes the body at least once
  • CCannot use conditions
  • DOnly works with files
Q154

A for loop is often preferred when:

  • AThe number of iterations is known or controlled by a counter
  • BNo repetition is needed
  • COnly strings are processed
  • DDynamic memory is allocated
Q155

Initialization, condition, and update commonly appear together in a:

  • Aif statement
  • Bfor loop
  • Cswitch statement
  • Dfunction prototype
Q156

An infinite loop is a loop that:

  • ARuns exactly once
  • BNever terminates on its own
  • CContains a comment
  • DUses an array
Q157

The loop variable in counting loops is commonly called:

  • AAccumulator only
  • BCounter or index
  • CCompiler
  • DPointer
Q158

An accumulator variable is used to:

  • AStore running totals
  • BHold filenames only
  • CReplace arrays
  • DCreate comments
Q159

A sentinel-controlled loop ends when:

  • AA special value is encountered
  • BMemory is full
  • CThe compiler stops
  • DA function returns void
Q160

A flag-controlled loop uses:

  • AA Boolean variable to control repetition
  • BA file pointer only
  • CA switch statement only
  • DMachine code
Q161

Which statement immediately exits the nearest loop in many languages?

  • Acontinue
  • Bbreak
  • Creturn always from file
  • Ddefault
Q162

Which statement skips the rest of the current iteration and proceeds to the next?

  • Abreak
  • Bcontinue
  • Ccase
  • Dtypedef
Q163

An off-by-one error in loops means:

  • AUsing a wrong data type
  • BIterating one time too many or too few
  • CReading from a file
  • DUsing recursion
Q164

The condition i < n in a counting loop usually causes i to take values:

  • A0 through n inclusive
  • B0 through n-1 if starting at 0
  • C1 through n+1
  • DOnly even numbers
Q165

Nested loops are loops:

  • AThat cannot terminate
  • BPlaced inside other loops
  • CUsed only for files
  • DWithout counters
Q166

A common use of nested loops is to:

  • AProcess rows and columns of a table
  • BCompile code
  • COpen a single file once
  • DDeclare constants
Q167

Loop tracing helps to:

  • AVisualize variable changes over iterations
  • BAllocate heap memory
  • CLink object files
  • DRename keywords
Q168

The update step of a loop is important because it:

  • AChanges source code
  • BMoves the loop toward termination
  • CCreates functions
  • DReads input
Q169

A pre-test loop checks its condition:

  • ABefore executing the body
  • BAfter every file read only
  • CAfter executing the body at least once
  • DNever
Q170

A post-test loop checks its condition:

  • ABefore entering the loop
  • BAfter executing the loop body
  • COnly during compilation
  • DOnly for arrays
Q171

To sum numbers from 1 to n, a variable often initialized to 0 is:

  • ACounter
  • BAccumulator
  • CIndex pointer
  • DString
Q172

To count how many times an event occurs, use a variable often initialized to:

  • A-1
  • B0
  • Cn
  • Dtrue
Q173

Which is a loop invariant?

  • AA property that remains true each iteration
  • BA syntax error
  • CA dynamic array
  • DA file mode
Q174

A common cause of infinite loops is:

  • AFailing to update the loop control variable
  • BUsing comments
  • CUsing constants
  • DPrinting output
Q175

The loop condition should eventually become false for:

  • AGuaranteed termination
  • BFaster graphics
  • CMore memory
  • DString concatenation
Q176

Which loop is most suitable for reading until end-of-file or sentinel?

  • Aswitch
  • Bwhile
  • Ctypedef
  • Dcase
Q177

The body of a loop contains:

  • AStatements repeated during each iteration
  • BOnly comments
  • COnly declarations in every language
  • DOnly one statement
Q178

A loop that processes every element of an array often uses:

  • AAn index from 0 to length-1
  • BOnly recursion
  • CNo condition
  • DA file handle
Q179

Loop unrolling generally refers to:

  • AA compiler or manual optimization reducing loop overhead
  • BAn error in while loops
  • CUsing recursion instead of iteration
  • DReading strings backward
Q180

Which statement about for and while loops is true?

  • AThey are both repetition constructs
  • BThey cannot be nested
  • CThey cannot use conditions
  • DThey are identical in syntax
Q181

A dry run of a loop usually records:

  • AProcessor temperature
  • BThe values of variables after each iteration
  • COnly comments
  • DThe executable size
Q182

When should break be used carefully?

  • ABecause overuse can make loop logic harder to follow
  • BBecause it always causes syntax errors
  • CBecause it cannot appear in loops
  • DBecause it changes data type
Q183

A loop controlled by user choice often depends on:

  • AA menu option or response flag
  • BOnly compiler settings
  • CMachine code
  • DStatic memory only
Q184

The expression i++ or similar usually means:

  • ADecrease i
  • BIncrease i by 1
  • CSet i to zero
  • DMultiply i
Q185

Reverse iteration over an array means:

  • AStarting near the end and moving backward
  • BSorting the array automatically
  • CUsing only recursion
  • DChanging element type
Q186

The main reason to avoid unnecessary nested loops is:

  • AThey may increase time complexity significantly
  • BThey cannot compile
  • CThey remove variables
  • DThey forbid input
Q187

A loop over a fixed number of times is often called:

  • ADefinite iteration
  • BInfinite recursion
  • CSelection
  • DFile mode
Q188

A loop whose number of repetitions depends on data is:

  • AIndefinite iteration
  • BCompile-time iteration
  • CType casting
  • DLinking
Q189

An index out of range inside a loop can cause:

  • ASyntax highlighting
  • BRuntime errors or incorrect behavior
  • CAutomatic repair
  • DCompiler linking
Q190

The continue statement usually affects:

  • AThe current iteration only
  • BAll future programs
  • CFile creation
  • DVariable declaration rules
Q191

Choosing correct initial values for counters and accumulators is important because:

  • AIt affects correctness of results
  • BIt changes compiler version
  • CIt removes loops
  • DIt creates new files
Q192

Which is an example of repetition?

  • AChecking one grade once
  • BPrinting numbers 1 to 100
  • CDeclaring a constant
  • DWriting a comment
Q193

A for-each style loop is often used to:

  • AVisit each element in a collection
  • BOpen network ports
  • CCreate compilers
  • DReplace functions
Q194

A loop condition based on user input should be re-evaluated:

  • AAt the correct point each iteration
  • BOnly after compilation
  • COnly before writing code
  • DNever
Q195

The statement total += value inside a loop is usually:

  • AAccumulation
  • BSelection
  • CFile reading
  • DPointer declaration
Q196

A loop can be replaced by recursion in some problems, but loops are often:

  • ASimpler for straightforward repetition
  • BImpossible to understand
  • CAlways slower
  • DOnly for strings
Q197

Which testing values are especially useful for loops?

  • ABoundary counts like 0, 1, and many iterations
  • BOnly random strings
  • COnly maximum memory
  • DOnly syntax examples
Q198

A nested loop printing a multiplication table most naturally uses:

  • ATwo counters
  • BA file and a pointer
  • COne comment
  • DA switch only
Q199

A loop’s time complexity often depends on:

  • AHow many times it iterates and work per iteration
  • BThe font of comments
  • CThe filename
  • DThe compiler brand
Q200

Good loop design requires clear initialization, condition, body, and:

  • AColor
  • BUpdate
  • CLinker
  • DHeader file
SECTION 5: Lists, Multidimensional Lists and Strings (Q201-Q250)
Q201

A list or array is primarily used to:

  • AStore multiple values of the same type under one name
  • BStore only one value
  • CReplace all functions
  • DCompile code
Q202

Array elements are typically stored in:

  • ARandom unrelated locations
  • BContiguous memory locations
  • CFiles only
  • DCPU registers only
Q203

The first element of an array in many languages has index:

  • A1
  • B0
  • C-1
  • DDepends but often 0
Q204

An array index is used to:

  • AOpen a file
  • BAccess a specific element
  • CDeclare a variable type
  • DCreate a loop automatically
Q205

The length or size of an array means:

  • AThe number of elements it can hold
  • BIts physical color
  • CThe compiler version
  • DIts file path
Q206

Accessing an index outside valid bounds can cause:

  • AOnly a comment
  • BErrors or undefined behavior
  • CAutomatic resizing in every language
  • DCompilation into machine code
Q207

Traversing an array means:

  • ADeleting it
  • BVisiting its elements one by one
  • CConverting it to a file
  • DChanging its type
Q208

Which loop is commonly used to process all array elements?

  • AA counting loop with an index
  • BA switch statement only
  • CNo loop is needed
  • DA linker command
Q209

A two-dimensional array is useful for representing:

  • AA single number
  • BRows and columns such as a matrix
  • COnly strings
  • DA Boolean flag
Q210

The element at row i and column j in a 2D array is often written as:

  • Aa(i,j) in all languages only
  • Ba[i][j] or equivalent
  • Ca<i,j>
  • Da{i}{j} only
Q211

Multidimensional arrays are often stored in memory using:

  • ARow-major or column-major order depending on language/system
  • BNo order
  • COnly file blocks
  • DRandom placement
Q212

Searching an unsorted array for a value using one-by-one checking is:

  • ABinary search
  • BLinear search
  • CHashing
  • DCompilation
Q213

Binary search requires the array to be:

  • ADynamic only
  • BSorted
  • CTwo-dimensional
  • DEmpty
Q214

Swapping two array elements is common in:

  • ASorting algorithms
  • BOnly file operations
  • CCompilation
  • DLinking
Q215

A string in many languages is:

  • AA sequence of characters
  • BA single integer
  • CA loop type
  • DA compiler
Q216

The length of a string usually means:

  • AIts memory address
  • BThe number of characters
  • CThe number of files
  • DIts index
Q217

Concatenating strings means:

  • AComparing them
  • BJoining them together
  • CDeleting them
  • DConverting to arrays only
Q218

A substring is:

  • AA whole file
  • BA portion of a string
  • CA pointer only
  • DA comment
Q219

String comparison is used to:

  • ACheck relative equality or order of strings
  • BAllocate memory
  • COpen files
  • DCreate arrays
Q220

In many languages, strings may require a special terminator or metadata to indicate:

  • AFont style
  • BWhere the string ends
  • CCompiler version
  • DWhether it is sorted
Q221

A character array used as a string often ends with:

  • AA null terminator in C-style languages
  • BA semicolon in memory
  • CA loop flag
  • DA linker
Q222

Copying one array to another usually requires:

  • AElement-by-element assignment or language-supported copy
  • BOnly changing the name
  • CNo storage
  • DA compiler switch
Q223

The average of n numbers stored in an array is found by:

  • ATaking the first number only
  • BSumming all elements and dividing by n
  • CSorting alphabetically
  • DUsing a switch
Q224

A common reason to use arrays is to:

  • AAvoid repeated variable names like score1, score2, score3
  • BReplace all conditions
  • CRemove loops
  • DPrevent input
Q225

An array declaration typically specifies:

  • AOnly comments
  • BIts type and size
  • CIts flowchart symbol
  • DIts case labels
Q226

Which of the following is a common array operation?

  • AInsertion
  • BTraversal
  • CUpdate
  • DAll of these
Q227

A jagged array generally means:

  • AEvery row has the same number of columns
  • BRows may have different lengths
  • CThe array is sorted
  • DIt contains only strings
Q228

The main diagonal of a square matrix contains elements where:

  • Arow == column
  • Brow > column
  • Crow < column
  • Dall are zero
Q229

Initializing an array means:

  • AGiving starting values to its elements
  • BPrinting it
  • CLinking it
  • DDeleting it
Q230

A frequency table can be implemented using:

  • AAn array of counts
  • BOnly a string
  • CA single Boolean
  • DA comment
Q231

Which of the following best describes an index variable?

  • AA variable used to access array/list positions
  • BA reserved keyword
  • CA file handle
  • DA function prototype
Q232

A common bug with arrays is:

  • ABuffer overflow or out-of-bounds access
  • BUsing comments
  • CCalling functions
  • DReading input
Q233

Sorting arranges data in:

  • ANo order
  • BA specific order such as ascending or descending
  • COnly file order
  • DPointer order
Q234

Bubble sort repeatedly:

  • ACompares and swaps adjacent elements if needed
  • BUses recursion only
  • CWorks only on strings
  • DRequires dynamic memory
Q235

Selection sort repeatedly selects:

  • AThe largest or smallest remaining element
  • BA random element
  • CA pointer
  • DA file
Q236

An array passed to a function often provides:

  • ABulk access to many related values
  • BNo usable data
  • COnly one character
  • DAutomatic sorting
Q237

A matrix addition algorithm usually uses:

  • ANested loops
  • BOnly one if statement
  • CNo variables
  • DA switch
Q238

To find the maximum element in an array, you usually:

  • ACompare each element with the current maximum
  • BRead only the first element
  • CSort comments
  • DUse file output only
Q239

A string traversal loop processes:

  • AEach character one by one
  • BOnly the first character
  • COnly digits
  • DOnly spaces
Q240

Whitespace handling in strings can matter because:

  • AInput methods may stop at spaces or include them depending on approach
  • BStrings cannot contain spaces
  • CCompilers ignore spaces always
  • DFiles cannot store spaces
Q241

A palindrome check on a string often compares:

  • ACharacters from the start and end moving inward
  • BOnly adjacent characters
  • CThe string length with zero
  • DOnly vowels
Q242

Which data structure is closest to a fixed-size list in basic programming?

  • AArray
  • BCompiler
  • CCPU
  • DLinker
Q243

An array element can usually be updated by:

  • AAssigning a new value to a valid index
  • BChanging the array name
  • CRecompiling the hardware
  • DUsing comments
Q244

A row-major traversal of a 2D array processes:

  • ARows first, then columns
  • BColumns first, then rows
  • COnly the diagonal
  • DOnly the last row
Q245

The total number of elements in a 2D array with r rows and c columns is:

  • Ar + c
  • Br * c
  • Cr – c
  • Dc / r
Q246

A list in higher-level languages may differ from a basic array because it can often:

  • AResize dynamically and hold more flexible structures
  • BNever store strings
  • COnly hold Booleans
  • DReplace the CPU
Q247

Parallel arrays mean:

  • ATwo or more arrays storing related information at corresponding indexes
  • BArrays on separate computers only
  • CArrays that are always sorted
  • DArrays without indexes
Q248

A common operation on strings is parsing, which means:

  • ABreaking a string into meaningful parts
  • BDeleting the whole string
  • CAllocating random memory
  • DSorting files
Q249

The memory organization of arrays helps make indexed access:

  • AEfficient
  • BImpossible
  • CAlways recursive
  • DDependent on comments
Q250

When copying strings in low-level languages, special care is needed to avoid:

  • ACompilation
  • BOverflow and missing terminators
  • CUsing loops
  • DUsing functions
SECTION 6: Functions, Modularity, Pointers, Memory and File I/O (Q251-Q300)
Q251

A function is primarily used to:

  • AStore only files
  • BGroup reusable statements to perform a task
  • CReplace all loops
  • DDeclare arrays only
Q252

Function modularity helps by:

  • AMaking programs harder to read
  • BBreaking problems into manageable parts
  • CRemoving all variables
  • DAvoiding testing
Q253

A function definition contains:

  • AThe actual code of the function
  • BOnly the function name
  • COnly comments
  • DThe executable file
Q254

A function call does what?

  • ADefines new syntax
  • BTransfers control to execute the function
  • CDeletes memory
  • DOpens a compiler
Q255

The values supplied to a function when it is called are:

  • AArguments
  • BComments
  • CHeaders
  • DLibraries
Q256

The variables listed in the function definition are:

  • AParameters
  • BConstants
  • CCase labels
  • DPointers only
Q257

A return value is:

  • AThe value sent back by a function
  • BAlways a string
  • COnly used in files
  • DA hardware signal
Q258

A void function typically:

  • AReturns no explicit value
  • BCannot print output
  • CCannot take parameters
  • DCannot be called
Q259

Local variables are usually accessible:

  • AAnywhere in the whole program
  • BOnly inside their function or block
  • COnly in files
  • DOnly by the linker
Q260

Global variables are variables that are:

  • AAccessible from a wider scope, often the whole file/program depending on language
  • BAlways stored in files
  • CAlways constants
  • DVisible only inside loops
Q261

Which is a good reason to avoid excessive global variables?

  • AThey can make programs harder to understand and maintain
  • BThey always cause syntax errors
  • CThey cannot store integers
  • DThey remove functions
Q262

A function prototype or declaration tells the compiler/interpreter about:

  • AThe function interface before use
  • BThe whole operating system
  • CThe file system only
  • DThe CPU model
Q263

Pass by value means:

  • AThe function receives a copy of the argument value
  • BThe function receives the original variable directly in all senses
  • CFiles are copied
  • DNo parameters are allowed
Q264

Pass by reference means:

  • AThe function can work with the caller’s original data through a reference/address mechanism
  • BArguments are always constants
  • CNo memory is used
  • DOnly strings are allowed
Q265

Recursion is when a function:

  • ACalls itself directly or indirectly
  • BContains only loops
  • CReads a file
  • DDeclares an array
Q266

A recursive function needs a base case to:

  • APrevent infinite recursion
  • BAllocate memory
  • COpen a file
  • DCompare strings
Q267

The call stack is used to store:

  • AFunction call information such as parameters and return addresses
  • BOnly array elements
  • COnly file names
  • DKeyboard input
Q268

Stack unwinding in recursion occurs when:

  • ARecursive calls return back toward the original caller
  • BInput is read
  • CA file is closed
  • DDynamic memory is allocated
Q269

A pointer usually stores:

  • AThe address of another variable/object
  • BOnly text
  • CA Boolean condition
  • DA compiler option
Q270

Dereferencing a pointer means:

  • AAccessing the value at the address it stores
  • BCreating a comment
  • CClosing a file
  • DLooping through a string
Q271

A null pointer/reference typically indicates:

  • AA valid memory address
  • BNo object/location is currently referenced
  • CAn integer value
  • DA syntax error
Q272

Dynamic memory allocation is useful when:

  • AThe required memory size is known only at runtime
  • BEverything is fixed at compile time
  • COnly global variables exist
  • DNo arrays are used
Q273

Static memory allocation generally means memory size is determined:

  • ADuring compilation or fixed definition time
  • BOnly after file input
  • CBy the linker while running
  • DRandomly
Q274

Heap memory is commonly associated with:

  • ADynamic allocation
  • BComments
  • CSwitch statements
  • DCase labels
Q275

A memory leak occurs when:

  • ADynamically allocated memory is no longer needed but not released
  • BA loop ends
  • CA file opens successfully
  • DA variable is declared
Q276

Dangling pointer/reference refers to:

  • AA pointer/reference that points to memory no longer valid
  • BA pointer storing zero safely
  • CA function name
  • DA string literal
Q277

Which operation is common with files?

  • AOpen, read/write, close
  • BCompile, link, flash
  • CAdd, subtract, multiply
  • DPush, pop, recurse
Q278

File I/O stands for:

  • AFile Input/Output
  • BFast Integer Operation
  • CFixed Instruction Order
  • DFinal Internal Object
Q279

Before reading or writing a file, a program usually needs to:

  • AOpen the file
  • BCreate a switch
  • CAllocate a pointer only
  • DSort arrays
Q280

Closing a file after use is important to:

  • ARelease resources and ensure data is properly handled
  • BIncrease syntax errors
  • CDelete memory automatically
  • DCreate loops
Q281

Text files store data as:

  • AHuman-readable characters
  • BOnly binary machine words
  • COnly pointers
  • DOnly arrays
Q282

Binary files store data in:

  • AA raw machine-oriented format
  • BOnly English sentences
  • COnly comments
  • DOnly CSV
Q283

End-of-file indicates:

  • AThere is no more data to read
  • BThe program compiled
  • CThe array is full
  • DA function ended
Q284

Which function design principle is good practice?

  • AOne function should do one clear task
  • BEvery function should be huge
  • CFunctions should always use globals
  • DNo comments are ever needed
Q285

Parameter names in a function definition are:

  • ALocal to that function
  • BGlobal everywhere
  • CAlways constants
  • DAlways pointers
Q286

Returning multiple results from a function can be done in some languages by:

  • AUsing references/pointers/structures as appropriate
  • BOnly by printing them
  • CNever possible
  • DChanging the CPU
Q287

A library function is:

  • AA prewritten function provided by language/library packages
  • BA variable name
  • CA flowchart symbol
  • DAn array type
Q288

Modular programming improves testing because:

  • AEach function can be tested more independently
  • BTesting becomes impossible
  • COnly global variables are allowed
  • DFiles cannot be used
Q289

A stack overflow can occur with recursion when:

  • AToo many recursive calls consume stack space
  • BA file is empty
  • CA string is concatenated
  • DA switch has many cases
Q290

Which best describes scope?

  • AWhere in the program a name is visible and usable
  • BThe speed of execution
  • CThe size of the CPU
  • DThe file extension
Q291

Lifetime of a variable refers to:

  • AHow long it exists in memory during execution
  • BHow long its name is
  • CIts array index
  • DIts file path
Q292

A reference parameter can allow a function to:

  • AModify the caller’s original variable
  • BOnly read constants
  • CDisable recursion
  • DAvoid all memory use
Q293

A pointer arithmetic mistake can lead to:

  • AInvalid memory access
  • BBetter readability
  • CAutomatic sorting
  • DCompilation of libraries
Q294

Which of the following is a common string function category?

  • ALength, copy, compare, concatenate
  • BCompile, link, boot, flash
  • CEncrypt, install, mount, print
  • DSort, swap, case, break
Q295

Reading a full line of text instead of a single word is useful when:

  • ASpaces must be included
  • BOnly numbers are allowed
  • CThe file is binary
  • DPointers are null
Q296

When writing records to a file, consistent format is important for:

  • ACorrect later reading/parsing
  • BChanging CPU speed
  • CAvoiding loops
  • DCreating classes only
Q297

A function should ideally communicate with the rest of the program through:

  • AParameters and return values as much as practical
  • BRandom globals everywhere
  • COnly comments
  • DOnly file I/O
Q298

Dynamic arrays/vectors are helpful because they:

  • ACan grow or shrink as needed depending on the language
  • BNever use memory
  • CCannot store strings
  • DReplace all functions
Q299

Error handling in file operations should check whether:

  • AThe file opened/read/wrote successfully
  • BThe compiler color changed
  • CThe pointer type is a keyword
  • DThe array is sorted
Q300

A command-line argument is an example of:

  • AInput supplied when starting a program
  • BA loop invariant
  • CA null pointer
  • DA 2D array

Leave a Reply

Your email address will not be published. Required fields are marked *