Computer science revision questions and well-explained
answers (30Q &A)
1
, Q1. What is a computer program?
Answer: A computer program is a set of instructions written in a programming language that
tells the computer how to perform specific tasks. Programs are designed to solve problems or
automate tasks, and they are executed by the computer's CPU (Central Processing Unit). The
process involves compiling or interpreting the code into machine language, which the hardware
can understand.
Q2. What is the difference between a compiler and an interpreter?
Answer: Both compilers and interpreters convert high-level programming language code into
machine code, but they work differently:
Compiler: It translates the entire source code into machine code at once, creating an
executable file (like .exe). Errors are detected after the whole code is compiled. It’s faster
during execution since the code is pre-compiled.
Interpreter: It translates the source code line by line and executes it immediately. This
makes it slower during execution, but it detects errors at runtime, which is useful for
debugging.
Q3. What is the difference between a stack and a queue?
Answer:
Stack: A stack is a data structure that follows the LIFO (Last In, First Out) principle. The
last element added is the first one to be removed. Common operations are push (add) and
pop (remove).
2