Introduction to Programming # MCQs Practice set

Q.1 Which of the following is a high-level programming language?

Assembly
C
Machine Code
Binary Code
Explanation - C is a high-level language, easier to read and write compared to machine or assembly code.
Correct answer is: C

Q.2 Which of these is used to store multiple values of the same type in a single variable?

Function
Array
Loop
Conditional Statement
Explanation - An array is a data structure used to store multiple values of the same type under a single name.
Correct answer is: Array

Q.3 Which of the following is NOT a programming paradigm?

Object-Oriented
Procedural
Functional
Hierarchical
Explanation - Hierarchical is not a programming paradigm. Common paradigms include Object-Oriented, Procedural, and Functional.
Correct answer is: Hierarchical

Q.4 In C, which symbol is used to end a statement?

{ }
.
;
:
Explanation - In C and many other languages, a semicolon ';' is used to terminate a statement.
Correct answer is: ;

Q.5 Which of these is used to make decisions in a program?

Loop
Array
Conditional Statement
Variable
Explanation - Conditional statements (like if-else) allow programs to execute different code based on conditions.
Correct answer is: Conditional Statement

Q.6 What is the output of: print(2 + 3 * 4) in Python?

20
14
24
9
Explanation - Python follows operator precedence: multiplication first, then addition. 3*4=12, 12+2=14.
Correct answer is: 14

Q.7 Which of the following is used to repeat a block of code multiple times?

Loop
Function
Class
Variable
Explanation - Loops (for, while) are used to execute code repeatedly based on a condition.
Correct answer is: Loop

Q.8 Which keyword is used to define a function in Python?

func
function
def
define
Explanation - The 'def' keyword is used to define functions in Python.
Correct answer is: def

Q.9 What does IDE stand for in programming?

Integrated Development Environment
Internal Debug Engine
Intermediate Data Editor
Interactive Design Element
Explanation - IDE is software that provides tools for programming including editor, compiler, debugger, etc.
Correct answer is: Integrated Development Environment

Q.10 Which data type is used to store text in most programming languages?

Integer
Float
String
Boolean
Explanation - Strings are used to store sequences of characters (text).
Correct answer is: String

Q.11 Which operator is used for equality comparison in most languages like C, C++, and Java?

=
==
!=
<=
Explanation - The '==' operator checks if two values are equal. '=' is for assignment.
Correct answer is: ==

Q.12 What is the purpose of a compiler?

Execute code line by line
Convert high-level code to machine code
Debug code
Store data
Explanation - A compiler translates high-level programming code into machine code that a computer can execute.
Correct answer is: Convert high-level code to machine code

Q.13 Which of the following is a loop that executes at least once?

For loop
While loop
Do-while loop
If-else
Explanation - A do-while loop executes its block first and checks the condition afterward, ensuring at least one execution.
Correct answer is: Do-while loop

Q.14 Which of these is a mutable data type in Python?

Tuple
List
String
Integer
Explanation - Lists can be changed (mutable), whereas tuples and strings are immutable.
Correct answer is: List

Q.15 What does 'int' represent in programming?

Integer
Interactive
Internal
Interrupt
Explanation - 'int' is a data type used to store whole numbers.
Correct answer is: Integer

Q.16 Which of these is a correct way to start a comment in Python?

// This is a comment
# This is a comment
/* This is a comment */
-- This is a comment
Explanation - Python uses '#' to indicate single-line comments.
Correct answer is: # This is a comment

Q.17 Which of the following is true about variables?

They can only store numbers
They store data values
They execute code
They are always constant
Explanation - Variables are used to store data values of different types in a program.
Correct answer is: They store data values

Q.18 Which of these is a logical operator in programming?

+
-
and
*
Explanation - Logical operators (and, or, not) are used to combine or invert boolean expressions.
Correct answer is: and

Q.19 Which of the following is NOT a valid Python identifier?

my_var
_myVar
2var
var2
Explanation - Identifiers cannot start with a number in Python.
Correct answer is: 2var

Q.20 Which of the following stores a single character?

Char
String
Integer
Float
Explanation - The 'char' data type is used to store a single character.
Correct answer is: Char

Q.21 Which of these is used to terminate a loop prematurely?

continue
break
stop
exit
Explanation - The 'break' statement immediately exits the loop it is in.
Correct answer is: break

Q.22 Which of the following is a correct syntax to create a function in C?

function myFunc() {}
def myFunc() {}
int myFunc() {}
create myFunc() {}
Explanation - In C, functions are defined with a return type, followed by the name and parameters.
Correct answer is: int myFunc() {}

Q.23 Which of these operators is used for modulus operation?

%
/
*
^
Explanation - The modulus operator '%' returns the remainder of a division operation.
Correct answer is: %

Q.24 Which of the following best describes a program?

A set of instructions executed by a computer
A type of computer hardware
A user interface
A network protocol
Explanation - A program is a sequence of instructions that a computer executes to perform a task.
Correct answer is: A set of instructions executed by a computer

Q.25 Which of these is the default value of a boolean variable in most programming languages?

0
1
True
False
Explanation - By default, boolean variables are often initialized to False.
Correct answer is: False