First 50 of 199 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.
Continue in the practice tool above to load more questions, 50 at a time.
Question 1Computer Fundamentals and Programming
In C, which header must be included to use the printf and scanf functions?
- stdio.h Correct answer.
- math.h
- string.h
- stdlib.h
Explanation
The stdio.h header declares the standard input/output functions, including printf and scanf, so a C program that calls them must include it. Other headers declare different facilities such as memory allocation or string handling.
Question 2Computer Fundamentals and Programming
What is the decimal value of the binary number 1011?
- 9
- 15
- 11 Correct answer.
- 13
Explanation
Evaluating place values from left to right gives 8 + 0 + 2 + 1, which equals 11. Each binary digit represents a power of two starting from 2^0 on the right.
Question 3Computer Fundamentals and Programming
Which data structure follows the Last-In-First-Out (LIFO) principle?
- Queue
- Linked list
- Binary tree
- Stack Correct answer.
Explanation
A stack inserts and removes elements at the same end, so the most recently pushed element is the first popped, which is the LIFO discipline. A queue instead removes from the opposite end from where insertion occurs.
Question 4Computer Fundamentals and Programming
In a C program, which keyword declares a variable whose value cannot be modified after initialization?
- extern
- volatile
- const Correct answer.
- static
Explanation
The const qualifier tells the compiler that the qualified object must not be modified through that name, so any assignment attempt is diagnosed. The other storage-class specifiers control lifetime, visibility, or optimization behavior instead.
Question 5Computer Fundamentals and Programming
What does the acronym CPU stand for in computer architecture?
- Core Peripheral Unit
- Control Processing Utility
- Central Program Utility
- Central Processing Unit Correct answer.
Explanation
The CPU, or Central Processing Unit, is the component that fetches, decodes, and executes instructions. It contains the control unit and the arithmetic logic unit.
Question 6Computer Fundamentals and Programming
Which operator in C is used to access the member of a structure through a pointer to that structure?
- ::
- &
- .
- -> Correct answer.
Explanation
The arrow operator -> combines dereferencing and member access, so ptr->member is equivalent to (*ptr).member. The dot operator requires the structure value itself rather than a pointer.
Question 7Computer Fundamentals and Programming
What is the primary purpose of an operating system's scheduler?
- To translate source code into machine code
- To decide which ready process runs on the CPU next Correct answer.
- To allocate disk blocks to files permanently
- To convert decimal numbers into binary
Explanation
The scheduler selects among ready processes and assigns the CPU according to a scheduling policy such as round robin or priority. It balances responsiveness, throughput, and fairness.
Question 8Computer Fundamentals and Programming
Which of the following is a valid identifier in C?
- 2nd_value
- _count Correct answer.
- total-sum
- float
Explanation
An identifier may begin with a letter or underscore and contain letters, digits, and underscores only. The name _count satisfies these rules and is not a reserved keyword.
Question 9Computer Fundamentals and Programming
A loop runs for i = 1 to 10 and adds i to a running total. What is the final total?
- 45
- 66
- 55 Correct answer.
- 50
Explanation
The sum of the integers from 1 through 10 is n(n+1)/2 = 10*11/2 = 55. The loop adds each value once, so the accumulator ends at 55.
Question 10Computer Fundamentals and Programming
What does the following C expression evaluate to when a = 7 and b = 3: a / b in integer arithmetic?
- 1
- 2.33
- 2 Correct answer.
- 3
Explanation
When both operands of the division operator are integers, C performs integer division and truncates the fractional part. Seven divided by three is 2.333, truncated to 2.
Question 11Computer Fundamentals and Programming
Which sorting algorithm has an average-case time complexity of O(n log n) and is generally not stable?
- Quicksort Correct answer.
- Bubble sort
- Selection sort
- Insertion sort
Explanation
Quicksort partitions around a pivot and achieves O(n log n) average time, but its standard in-place partitioning can reorder equal keys, making it unstable. Its worst case degrades to O(n^2) with poor pivot choices.
Question 12Computer Fundamentals and Programming
What is the output of the following C code fragment: int x = 5; printf("%d", x++);
- 4
- 6
- 5 Correct answer.
- Undefined behavior
Explanation
The postfix increment operator yields the current value of x and then increments it. The printf call therefore receives 5, and x becomes 6 only after the expression is evaluated.
Question 13Computer Fundamentals and Programming
Which memory segment typically stores function-local variables that are not declared static?
- Stack Correct answer.
- Heap
- Text segment
- Data segment
Explanation
Automatic local variables are allocated on the call stack when a function is entered and released when it returns. The heap is used for dynamic allocation, while data and text hold globals and code.
Question 14Computer Fundamentals and Programming
Which logic gate produces a HIGH output only when all of its inputs are HIGH?
- NOR gate
- OR gate
- AND gate Correct answer.
- XOR gate
Explanation
An AND gate outputs 1 only for the input combination in which every input is 1. Any 0 input forces the output to 0.
Question 15Computer Fundamentals and Programming
What is the output of the following C statement: printf("%d", 10 % 3);
- 3.33
- 3
- 1 Correct answer.
- 0
Explanation
The modulus operator returns the remainder of integer division. Ten divided by three leaves a remainder of 1.
Question 16Computer Fundamentals and Programming
In a binary search on a sorted array of n elements, what is the maximum number of comparisons needed?
- n
- log2(n) + 1 Correct answer.
- n squared
- n/2
Explanation
Binary search halves the search interval each iteration, so at most about log base 2 of n plus one comparisons are required. This logarithmic bound is why the array must be sorted beforehand.
Question 17Computer Fundamentals and Programming
Which of the following best describes a compiler as opposed to an interpreter?
- It links libraries at run time only
- It converts machine code back into source code
- It translates the entire source program into machine code before execution Correct answer.
- It executes source code line by line without producing an object file
Explanation
A compiler translates the whole source program into an object or executable form prior to execution, allowing errors to be reported before the program runs. An interpreter instead analyzes and executes statements incrementally.
Question 18Computer Fundamentals and Programming
What is the result of the bitwise expression 6 & 3 in C?
- 1
- 7
- 2 Correct answer.
- 5
Explanation
Six is 110 in binary and three is 011. The bitwise AND keeps a bit only where both operands have a 1, producing 010, which is decimal 2.
Question 19Computer Fundamentals and Programming
Which statement about the time complexity of accessing an element by index in an array is correct?
- It is O(n) because the array must be scanned
- It is O(n log n) because elements must be sorted first
- It is O(1) because the address is computed directly from the base address and index Correct answer.
- It is O(log n) because the array is searched by halving
Explanation
Array elements occupy contiguous memory, so the address of element i is base plus i times the element size, giving constant-time access. No scanning or comparison is required.
Question 20Computer Fundamentals and Programming
What is the value of the expression 2 + 3 * 4 - 6 / 2 in C, given integer operands?
- 5
- 11 Correct answer.
- 8
- 14
Explanation
Multiplication and division bind tighter than addition and subtraction, so the expression becomes 2 + 12 - 3. Evaluating left to right gives 14 minus 3, which is 11.
Question 21Computer Fundamentals and Programming
A recursive function lacks a base case. What is the most likely consequence when it is called?
- The compiler rejects the program at compile time
- The call stack keeps growing until a stack overflow occurs Correct answer.
- The recursion is automatically converted into a loop by the compiler
- The function returns a default value of zero
Explanation
Without a terminating condition each call invokes another call, and the activation records accumulate on the stack until its limit is exceeded. The typical observable result is a stack overflow or segmentation fault at run time.
Question 22Computer Fundamentals and Programming
Two processes each hold one resource and wait for the resource held by the other. Which condition does this scenario illustrate?
- Deadlock Correct answer.
- Race condition
- Thrashing
- Starvation
Explanation
This is a circular wait, one of the four Coffman conditions for deadlock, so neither process can proceed. Deadlock requires mutual exclusion, hold-and-wait, no preemption, and circular wait together.
Question 23Computer Fundamentals and Programming
Consider a C function that takes an array parameter declared as int arr[]. What does the function actually receive?
- A reference that enforces bounds checking
- A full copy of the array
- The length of the array followed by its elements
- A pointer to the first element of the array Correct answer.
Explanation
In C an array parameter is adjusted to a pointer to its first element, so the function receives an address rather than a copy. Consequently the function cannot determine the array length from the parameter alone and needs a separate size argument.
Question 24Computer Fundamentals and Programming
A hash table uses a table size of 10 and the hash function h(k) = k mod 10 with linear probing. After inserting keys 12, 22, and 32 in that order, at which index is key 32 finally stored?
- 3
- 2
- 4 Correct answer.
- 0
Explanation
Key 12 hashes to index 2 and is stored there. Key 22 also hashes to 2, collides, and probes to 3. Key 32 hashes to 2, finds 2 and 3 occupied, and settles at index 4.
Question 25Computer Fundamentals and Programming
A program declares a local pointer, assigns it the result of malloc, and never calls free before the function returns. Which statement best characterizes the problem?
- A buffer overflow, because the block is too small
- A dangling pointer, because the block was already freed
- A syntax error, because malloc requires a cast in C
- A memory leak, because the heap block remains allocated after the pointer is lost Correct answer.
Explanation
The heap block stays allocated for the life of the process, but the only pointer to it is destroyed when the function returns, so the memory can no longer be released. This is the classic memory leak pattern.
Question 26Computer Fundamentals and Programming
In C, which header file must be included to use the malloc and free functions correctly?
- stdio.h
- string.h
- stdlib.h Correct answer.
- math.h
Explanation
The malloc, calloc, realloc and free functions are declared in stdlib.h, so that header must be included before they are used. Without the declaration, the compiler may assume an incorrect return type and produce warnings or undefined behaviour.
Question 27Computer Fundamentals and Programming
Which number system is used internally by digital computers to represent and process data at the hardware level?
- Decimal
- Roman
- Hexadecimal
- Binary Correct answer.
Explanation
Digital circuits have two stable states, so data is stored and manipulated in binary using 0 and 1. Hexadecimal is only a compact notation for humans to read binary values, not the internal representation.
Question 28Computer Fundamentals and Programming
A technician needs a storage medium that is non-volatile, allows block-level random access, and contains no moving parts. Which device best fits these requirements?
- Magnetic hard disk drive
- Cache memory
- DRAM module
- Solid-state drive Correct answer.
Explanation
A solid-state drive uses flash memory, retains data without power, supports random block access, and has no mechanical parts. DRAM and cache are volatile, and a magnetic hard disk contains spinning platters and moving heads.
Question 29Computer Fundamentals and Programming
Which of the following is the binary equivalent of the decimal number 45?
- 100101
- 101011
- 110101
- 101101 Correct answer.
Explanation
Repeated division by two gives remainders that read upward as 101101, and 32 + 8 + 4 + 1 equals 45. Checking the place values confirms that only 101101 sums to the required decimal value.
Question 30Computer Fundamentals and Programming
In C, what is the effect of declaring a variable with the const qualifier?
- The variable is stored in read-only memory at all times
- The program cannot modify the variable after its initialisation Correct answer.
- The variable is automatically shared between all functions
- The variable's value is recomputed on every access
Explanation
The const qualifier tells the compiler that the object must not be modified after initialisation, and any attempt to assign to it is diagnosed. It does not by itself guarantee placement in read-only memory, which depends on the storage class and platform.
Question 31Computer Fundamentals and Programming
A stack is used to evaluate a postfix expression. Which sequence of operations correctly processes the expression 5 3 + 2 *?
- Push 5, add 3, push 2, multiply
- Push 5, push 3, add, push 2, multiply Correct answer.
- Push 5, push 3, multiply, push 2, add
- Push 5, push 3, push 2, then add and multiply
Explanation
Postfix evaluation pushes operands and applies an operator to the top two stack values. Reading left to right, 5 and 3 are pushed, the plus pops them and pushes 8, then 2 is pushed and the multiply yields 16.
Question 32Computer Fundamentals and Programming
Which statement correctly describes the difference between a structure and a union in C?
- A structure shares storage among members, while a union allocates separate storage for each member
- A union can hold members of only one data type
- A structure allocates storage for all members simultaneously, while a union shares one storage area among its members Correct answer.
- A union may contain at most two members
Explanation
A structure reserves space for every member at the same time, so all members can hold values concurrently. A union reserves only enough space for its largest member, and the members overlap, so only one value is meaningful at a time.
Question 33Computer Fundamentals and Programming
In a relational database table, which key uniquely identifies each row and must never contain a null value?
- Foreign key
- Primary key Correct answer.
- Alternate key
- Candidate key
Explanation
The primary key enforces both uniqueness and the NOT NULL constraint for every row in the table. Other keys may be unique, but only the primary key is defined as the chosen unique identifier with no nulls.
Question 34Computer Fundamentals and Programming
What is the decimal value of the hexadecimal number 2F?
- 31
- 63
- 47 Correct answer.
- 45
Explanation
The digit 2 occupies the sixteens place and F represents 15 in the units place. Therefore 2 × 16 + 15 equals 47.
Question 35Computer Fundamentals and Programming
A C program passes a variable to a function by value. What happens to the original variable when the function modifies its parameter?
- The original variable changes only if it is declared static
- The original variable changes because the parameter aliases it
- The program fails to compile because parameters cannot be modified
- The original variable is unchanged because the parameter is a separate copy Correct answer.
Explanation
In call by value the argument's value is copied into the parameter, so assignments inside the function affect only the copy. To let a function modify the caller's variable, the caller must pass its address and the function must dereference a pointer.
Question 36Computer Fundamentals and Programming
Which of the following best describes the role of a device driver in an operating system?
- It translates file names into disk block addresses
- It provides the software interface that lets the kernel control a specific hardware device Correct answer.
- It manages the allocation of virtual memory pages
- It schedules user processes onto the CPU
Explanation
A device driver contains the device-specific code that the kernel calls to initialise, read from, write to, and control a particular piece of hardware. It hides hardware details behind a uniform interface used by the rest of the operating system.
Question 37Computer Fundamentals and Programming
A binary tree has 7 nodes arranged as a perfect tree of height 2, with the root at level 0. How many leaf nodes does it contain?
- 7
- 3
- 4 Correct answer.
- 2
Explanation
A perfect binary tree of height h has 2^(h+1) − 1 nodes and 2^h leaves. With h equal to 2, the number of leaves is 2^2, which is 4.
Question 38Computer Fundamentals and Programming
In C, what does the expression sizeof(char) evaluate to on every conforming implementation?
- 4
- 1 Correct answer.
- 2
- It depends on the platform's word size
Explanation
The C standard defines sizeof(char) as exactly 1, because the char type is the unit in which object sizes are measured. The number of bits in a byte may vary by platform, but the size of char is always one.
Question 39Computer Fundamentals and Programming
A program must store a set of up to 10,000 integers and perform many fast membership tests. Which structure gives average O(1) membership testing while still storing the values?
- Unsorted array searched linearly
- Hash table with a good hash function Correct answer.
- Sorted singly linked list
- Balanced binary search tree
Explanation
A hash table maps each key to a bucket, so a membership test examines only the expected constant number of entries when the load factor is controlled. The other structures require time proportional to the number of stored elements or their logarithm.
Question 40Computer Fundamentals and Programming
Consider a C loop: for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { total += i * j; } } with total starting at 0. What is the final value of total?
- 9
- 6
- 18 Correct answer.
- 12
Explanation
For each i the inner loop adds i × 0, i × 1 and i × 2, which sums to 3i. Summing 3i for i from 0 to 3 gives 3 × (0 + 1 + 2 + 3), which equals 18.
Question 41Digital Logic Design and Microprocessors
In a synchronous digital system, what is the primary purpose of the clock signal?
- To supply the operating voltage required by CMOS logic gates
- To convert parallel data into serial form for transmission
- To select which memory address is read during a bus cycle
- To provide a common time reference that coordinates state changes in sequential elements Correct answer.
Explanation
A clock is a periodic reference that determines when registers and flip-flops sample inputs and update outputs. Because all sequential elements share this reference, the system avoids race conditions and behaves deterministically. Voltage supply and address selection are separate functions.
Question 42Digital Logic Design and Microprocessors
What is the binary representation of the decimal number 45?
- 110101
- 101011
- 101101 Correct answer.
- 100111
Explanation
Using positional weights from 32 down: 45 = 32 + 8 + 4 + 1, so bits at positions 5, 3, 2 and 0 are set, giving 101101. Checking: 32+8+4+1 = 45.
Question 43Digital Logic Design and Microprocessors
What does a 2-to-4 line decoder with an active-HIGH enable produce when the enable is LOW?
- All outputs are forced LOW Correct answer.
- All outputs are forced HIGH
- The outputs follow the two select inputs
- Only output 0 is HIGH
Explanation
When the enable input is deasserted, a decoder disables all of its outputs; with active-HIGH outputs this means every output is driven LOW. Only when enabled does exactly one output, chosen by the select lines, go HIGH.
Question 44Digital Logic Design and Microprocessors
What is the hexadecimal equivalent of the binary value 1111 1010?
- EA
- FA Correct answer.
- AF
- F5
Explanation
Grouping the binary number into nibbles gives 1111 = F and 1010 = A, so the value is FA. Hexadecimal notation maps each four-bit group directly to one digit.
Question 45Digital Logic Design and Microprocessors
In the 8085 microprocessor, which register pair is used to hold the 16-bit memory address during instruction fetch?
- BC
- SP
- DE
- HL Correct answer.
Explanation
The 8085 uses the HL pair as the default memory pointer, placing H on the high address lines and L on the low address lines during fetch. BC and DE are general-purpose pairs used for data, and SP holds the stack top.
Question 46Digital Logic Design and Microprocessors
What is the main advantage of CMOS logic over older bipolar logic families in static operation?
- It has much lower static power consumption because one transistor of each pair is off Correct answer.
- It switches faster than every other logic family at all supply voltages
- It requires no power supply connections
- It can drive unlimited fan-out without buffering
Explanation
A CMOS gate uses complementary pull-up and pull-down networks, so in a steady state one network is off and essentially no current flows from supply to ground. Power is drawn mainly during switching. Fan-out and speed are still finite and depend on loading and supply.
Question 47Digital Logic Design and Microprocessors
Which of the following best describes the function of an ALU inside a microprocessor?
- It manages the timing of the system clock generator
- It stores the program counter value during interrupts
- It performs arithmetic and bitwise logical operations on operands Correct answer.
- It converts analog sensor signals into digital codes
Explanation
The arithmetic logic unit executes operations such as addition, subtraction, AND, OR and shift on data presented by the control unit. It sets condition flags based on the result. Storage, conversion and clock generation belong to other blocks.
Question 48Digital Logic Design and Microprocessors
A 4-bit binary counter is clocked continuously. If it currently reads 1110, what value does it hold after two clock pulses?
- 1100
- 1111
- 0000 Correct answer.
- 0001
Explanation
From 1110 the next state is 1111, and the following pulse wraps the counter to 0000. Two pulses therefore advance the count by two positions modulo 16.
Question 49Digital Logic Design and Microprocessors
Simplify the Boolean expression F = A'B + AB + AB'.
- AB
- A'B'
- A + A'B
- A + B Correct answer.
Explanation
The terms A'B and AB combine to B(A' + A) = B, leaving F = B + AB'. Then B + AB' = B + A by the absorption/consensus identity, giving A + B. A truth-table check confirms the expression is 1 except when A = B = 0.
Question 50Digital Logic Design and Microprocessors
A D flip-flop has D = 1 and the clock input is rising. Just before the rising edge the output Q was 0. What is Q immediately after the edge (ignoring propagation delay)?
- 1 Correct answer.
- Toggles to the complement of the previous state
- Undefined
- 0
Explanation
A D flip-flop samples its data input at the active clock edge and copies it to the output, so Q becomes 1. It does not toggle or hold unless the input or enable dictates it.