NEW
Font size
WorksheetsCPROG 1 | Long Quiz - MIDTERMS
Total questions: 40
Worksheet time: 40mins
Which term describes a solution that can be expressed as a finite, logically arranged sequence of steps?
Algorithmic solution
Heuristic solution
Iterative solution
Randomized solution
A heuristic solution is best described as:
Based on finite steps only
Based on rules of thumb and past experience
Guaranteed to be optimal
Independent of human judgment
Which is the correct order of the general problem‑solving steps?
Identify alternatives → Identify problem → Evaluate → Select best → List instructions → Understand
Identify problem → Understand → Identify alternatives → Select best → List instructions → Evaluate
Understand → Evaluate → List instructions → Identify problem → Select best → Identify alternatives
Select best → Identify alternatives → Evaluate → List instructions → Understand → Identify problem
In the programming process, which phase includes 'Analysis and Specification' and 'General Solution'?
Implementation phase
Maintenance phase
Problem‑solving phase
Testing phase
Which pair belongs to the Implementation phase?
Verify and Use
Translate algorithm into code and Test
Analysis and Specification
Maintain and Modify
Which property of algorithms requires that execution finishes after a bounded number of operations?
Effectiveness
Finiteness
Scope definition
Input/Output definition
Which pseudocode convention is recommended in the lessons?
End statements with semicolons
Use punctuation to terminate lines
Every program starts with START and ends with STOP
Combine multiple actions in one line if short
Which of the following is NOT among the commonly used pseudolanguage operations listed?
DISPLAY
COMPUTE
EXIT
SYNCHRONIZE
In flowcharting, which symbol denotes the beginning or end of a process?
Process
Terminal
Decision
On‑page connector
Which flowchart type is primarily used by programmers to show program logic and operations performed?
Data flow diagram
Program flowchart
System flowchart
Entity‑relationship diagram
Which statement about flowcharts in the lesson is TRUE?
They are tied to a specific programming language
They help trace logic errors before coding
They cannot represent branching
They replace the need for testing
Which property ensures each algorithmic step has a single interpretation?
Sequence definition
Absence of ambiguity
Scope definition
Effectiveness
According to the lesson, algorithms are independent of:
Programming language
Input and output
Logical sequence
Data types
In pseudocode formatting, each statement should:
Perform multiple actions for brevity
Use punctuation to end statements
Appear on a single line if possible and be indented
Be aligned with START
The for loop is considered 'predefined' because:
It has no counter
The number of iterations is predetermined in the loop's header
It always runs indefinitely
It checks its condition after the loop body
In the for loop header for (init; condition; increment), when is the increment part executed?
Before the first iteration
Before checking the condition
After each iteration of the loop body
Only if the condition is FALSE
Which is a logical error noted in the lesson?
Indenting the loop body
Placing a semicolon right after the for header
Using braces for multiple statements
Initializing the counter to 0
Which advice is given about the for loop's counter?
Change it inside the body to speed up loops
Never change the value of the counter inside the loop body
Use floating‑point counters
Counters must decrease only
The while loop is described as:
Closed‑ended loop with predetermined iterations
Open‑ended/event‑controlled loop
A loop that always executes at least once
A loop with no condition
The general form of the while loop places the condition:
After the loop body
Before the loop body in parentheses
Inside the printf statement
In the increment part
The do‑while loop differs from while because it:
Evaluates the condition before the first iteration
Always executes at least once
Has no condition
Cannot use braces
In a do‑while loop, where is the condition checked?
At the top
In the middle
At the bottom, after the body
It's not checked
According to the lesson, when the for loop's condition becomes FALSE (0):
The loop repeats
The program terminates
Control passes to the statement after the loop
The increment runs again then exits
In the sample averaging program with do‑while, the variable average is computed:
Before the loop starts
Inside the loop
After the loop using the accumulated sum
Using integer division only
Which of the following is identified in the lesson as a loop control statement?
return
break
halt
pause
A while loop that starts with x = 1; while (x <= 10) { ... } will keep iterating as long as:
x is exactly 10
The condition evaluates to TRUE (1)
The increment happens first
x becomes negative
In a for loop, the body can be:
Only a single statement
Only a function call
A single statement or a block of statements
Only an empty statement
An array in C stores:
Elements of different data types
Elements of the same data type in contiguous memory
Data in scattered memory locations
Only characters
Which is NOT a listed characteristic of arrays in C?
Fixed size
Homogeneous elements
Indexed access
Dynamic resizing at runtime
The index of the first element in a C array typically starts at:
1
-1
0
Any value
What is the correct declaration of an array of five integers?
int numbers[5];
int numbers(5);
array int numbers[5];
int[5] numbers = {};
Given int numbers[5] = {10, 20};, the remaining elements are:
Unchanged
Random values
All set to 0
All set to -1
If array size is omitted and initialized as int numbers[] = {10,20,30};, the array size becomes:
2
3
0
4
Accessing the third element of numbers uses:
numbers(3)
numbers[2]
*numbers + 3
&numbers[3]
To traverse and print elements of an array, the lesson uses:
A switch statement
A for loop iterating over indices
A goto label
A recursive function
In fixed‑size arrays, 'insertion' typically:
Increases the array's capacity
Overwrites an existing element at a given index
Requires realloc by default
Is not possible in C
Deleting an element from an array is commonly simulated by:
Setting the index to NULL
Shifting subsequent elements left
Freeing the array
Setting array size smaller
The search example in the lesson returns -1 when:
The target is found
The target is not found
The array is full
The array contains 0
Regarding memory layout, consecutive int elements differ in addresses by:
1 byte
2 bytes
4 bytes
8 bytes
The relationship between arrays and pointers shown in the lesson implies that int *ptr = numbers; then *(ptr + 1) equals:
numbers[0]
numbers[1]
numbers[2]
The address of numbers
