Chapter 1: Problem Solving and Algorithm Designing
1. The first step in problem solving is:
A) Designing the program
B) Writing the code
C) Understanding the problem
D) Running the program
Explanation: Before designing or coding, the problem must be clearly understood to identify
what needs solving.
2. A finite set of instructions to solve a problem is called:
A) Flowchart
B) Code
C) Algorithm
D) Program
Explanation: An algorithm is a step-by-step method used to solve a problem logically.
3. The graphical representation of an algorithm is called:
A) Syntax tree
B) Flowchart
C) Pseudocode
D) Block diagram
Explanation: Flowcharts use symbols to represent the logical flow of steps in an algorithm.
4. Which of the following is NOT a characteristic of a good algorithm?
A) Clarity
B) Ambiguity
C) Effectiveness
D) Finiteness
Explanation: A good algorithm must be unambiguous, clear, and must finish in finite steps.
5. A parallelogram in a flowchart is used for:
A) Process
B) Decision
C) Input/Output
D) Loop
Explanation: Input and output operations are represented by a parallelogram.
6. A diamond symbol in a flowchart represents:
A) Start
B) Output
C) Decision
D) Process
Explanation: Decisions (Yes/No or True/False) are represented by a diamond shape.
7. A rectangle in a flowchart represents:
A) Process
B) Decision
C) Input
D) Output
Explanation: A process or operation is shown using a rectangle.
8. Which of the following is used to describe an algorithm in plain language?
A) Flowchart
B) Syntax
C) Pseudocode
D) Compiler
Explanation: Pseudocode explains algorithmic logic in simple, structured language without
programming syntax.
9. A good algorithm should have:
A) Infinite steps
B) Finite steps
C) Random structure
D) Variable length
Explanation: Algorithms must be finite to ensure the problem is solved in a limited time.
10. A problem solving approach in computer science is called:
A) Typing
B) Algorithmic thinking
C) Compilation
D) Debugging
Explanation: Algorithmic thinking involves breaking problems into steps that a computer can
solve.
11. Which of the following is used for decision making in flowcharts?
A) Rectangle
B) Diamond
C) Oval
D) Circle
Explanation: Decisions in logic (e.g., if-else) are represented by diamonds.
12. An algorithm must:
A) Run forever
B) Produce at least one result
C) Be unclear
D) Ignore logic
Explanation: Algorithms are goal-oriented and must produce a result or solution.
13. In a flowchart, the terminator symbol (start/end) is:
A) Rectangle
B) Diamond
C) Oval
D) Parallelogram
Explanation: Ovals mark the beginning and end of a flowchart.
14. What is the main purpose of an algorithm?
A) To draw diagrams
B) To solve problems logically
C) To calculate speed
D) To write code directly
Explanation: Algorithms help solve problems step-by-step before coding begins.
15. A loop structure in algorithms is used to:
A) Repeat steps
B) Make decisions
C) Start execution
D) Stop the program
Explanation: Loops allow repeating a sequence until a condition is met.
16. The step-by-step plan of solving a problem is called:
A) Debugging
B) Algorithm
C) Coding
D) Logic gate
Explanation: An algorithm is the organized series of steps to solve a problem.
17. Which symbol is used to represent flow of control in a flowchart?
A) Circle
B) Box
C) Arrow
D) Diamond
Explanation: Arrows indicate the sequence of steps in a flowchart.
18. Which of the following is NOT a benefit of flowcharts?
A) Better understanding
B) Increases coding speed only
C) Error detection
D) Communication tool
Explanation: Flowcharts aid in logic and communication but don't directly speed up coding.
19. A dry run of an algorithm helps in:
A) Adding code
B) Checking logic manually
C) Installing software
D) Upgrading hardware
Explanation: A dry run manually traces an algorithm to verify its correctness.
20. What is the correct order of problem-solving steps?
A) Understand → Plan → Code → Test
B) Code → Plan → Test → Understand
C) Test → Understand → Code → Plan
D) Code → Test → Understand → Run
Explanation: Correct order is understanding, planning (algorithm), coding, and then testing.
21. Which tool is best for communicating the solution logic to others?
A) Code
B) Flowchart
C) Hardware
D) Monitor
Explanation: Flowcharts visually communicate logic clearly and simply.
22. Which of the following should be avoided in algorithm writing?
A) Simplicity
B) Unclear steps
C) Definite instructions
D) Termination
Explanation: Unclear steps lead to confusion and incorrect solutions.
23. Why are algorithms useful before programming?
A) Reduce hardware usage
B) Help structure logic clearly
C) Save typing time
D) Increase program size
Explanation: Algorithms outline logic before implementation, reducing confusion.
24. An algorithm should always:
A) Produce the correct output
B) Work with any hardware
C) Include pictures
D) Require long instructions
Explanation: Accuracy of output is a key requirement of an algorithm.
25. Which of these symbols is never used in flowcharts?
A) Diamond
B) Oval
C) Rectangle
D) Triangle
Explanation: Triangle is not a standard flowchart symbol.
26. What helps break a problem into smaller tasks?
A) Printer
B) Program
C) Algorithm design
D) Scanner
Explanation: Algorithm design helps divide a complex problem into smaller manageable steps.
27. Decision-making in algorithms is based on:
A) Guess
B) Conditions
C) Timing
D) Input size
Explanation: Decisions are made using conditional logic (e.g., IF statements).
28. Which of these is a tool for planning logic before coding?
A) Flowchart
B) Hard disk
C) RAM
D) CPU
Explanation: Flowcharts help design logic before implementing in code.
29. Why should an algorithm be simple?
A) To look short
B) To make it easy to understand and debug
C) To avoid flowcharts
D) To reduce input
Explanation: Simplicity ensures clarity, making debugging and implementation easier.
30. Which of the following is essential before converting logic into a program?
A) Designing an algorithm and flowchart
B) Typing fast
C) Installing compiler
D) Creating a folder
Explanation: Algorithm and flowchart are crucial planning tools before coding.
Chapter 2: Basics of Programming in C++
1. C++ is a:
A) Functional language
B) Object-oriented programming language
C) Machine-level language
D) Markup language
Explanation: C++ supports object-oriented features like classes and inheritance.
2. The extension of a C++ source file is usually:
A) .txt
B) .java
C) .cpp
D) .exe
Explanation: C++ programs are saved with the .cpp extension before compilation.
3. The smallest individual unit in a C++ program is called:
A) Constant
B) Token
C) Loop
D) Statement
Explanation: Tokens are the smallest units like keywords, identifiers, and symbols.
4. A group of instructions given to the computer is known as:
A) Command
B) Program
C) Compiler
D) Header
Explanation: A program is a sequence of instructions written to perform a task.
5. The function where execution of a C++ program begins is:
A) start()
B) open()
C) execute()
D) main()
Explanation: main() is the entry point of every C++ program.
6. Which of these is a correct comment in C++?
A)
B) \* comment \*
C) ## comment
D) // comment
Explanation: // is used for single-line comments in C++.
7. Which header file is used for input and output operations?
A) iostream.h
B) stdio.h
C) conio.h
D) iostream
Explanation: In modern C++, #include <iostream> is used for input and output streams.
8. The operator << is used for:
A) Assignment
B) Output (in cout)
C) Input (in cin)
D) Comments
Explanation: << is the insertion operator used with cout.
9. The operator >> is used with:
A) cout
B) cin
C) return
D) main
Explanation: >> is the extraction operator used to get input from the user via cin.
10. The keyword used to declare a variable is:
A) define
B) int
C) header
D) get
Explanation: int is a data type keyword that also acts as a declaration for integer variables.
11. Which symbol ends a statement in C++?
A) :
B) ,
C) '
D) ;
Explanation: Every statement in C++ ends with a semicolon (;).
12. Which of the following is not a valid data type in C++?
A) float
B) int
C) char
D) real
Explanation: real is not a valid C++ data type; float is used for decimal values.
13. What is the result of 5 / 2 in C++ (both integers)?
A) 2.5
B) 2
C) 0
D) 3
Explanation: Integer division in C++ truncates the decimal part, so 5 / 2 = 2.
14. What will cout << "Hello"; do?
A) Display Hello on screen
B) Take input
C) Store a value
D) Cause an error
Explanation: cout displays the message on the screen using the insertion operator.
15. Which character is used to include header files?
A) %
B) #
C) &
D) @
Explanation: The # symbol is used in preprocessor directives like #include.
16. A variable must be ______ before use.
A) Executed
B) Declared
C) Assigned
D) Output
Explanation: All variables must be declared with a data type before use.
17. The function cin is used for:
A) Output
B) Storing
C) Input
D) Returning values
Explanation: cin (character input) takes input from the user.
18. What is the output of cout << 3 + 2;?
A) 32
B) 5
C) 3+2
D) Error
Explanation: C++ evaluates the expression 3 + 2 and displays 5.
19. Keywords in C++ are:
A) User-defined
B) Predefined and reserved
C) Changeable
D) Ignored by compiler
Explanation: Keywords are reserved words that have special meaning in C++.
20. The term "syntax" refers to:
A) Variable name
B) Execution order
C) Rules of writing statements
D) Loop count
Explanation: Syntax defines how instructions must be written correctly in a language.
21. If you forget to put ; at the end of a statement, you get a:
A) Warning
B) Logic error
C) Syntax error
D) Run-time error
Explanation: Missing semicolon causes a syntax error during compilation.
22. Which data type is used to store characters?
A) int
B) char
C) float
D) bool
Explanation: char is used for single character storage.
23. Which of the following is a valid identifier in C++?
A) 2num
B) float
C) user_name
D) char
Explanation: user_name is a valid identifier; it does not start with a digit and is not a keyword.
24. To get a new line in output, use:
A) /line
B) \n
C) endl()
D) exit
Explanation: \n is the escape sequence for a new line in strings.
25. What does return 0; indicate in main()?
A) Program error
B) Wrong output
C) Successful termination
D) Function call
Explanation: return 0; means the program ended successfully.
26. How many times is main() used in a C++ program?
A) Once
B) Twice
C) Optional
D) As many as needed
Explanation: Only one main() function is allowed and required per C++ program.
27. What is the default value of an uninitialized integer in C++?
A) 1
B) -1
C) Garbage value
D) 0
Explanation: Local uninitialized variables contain garbage values in C++.
28. C++ was developed by:
A) James Gosling
B) Bjarne Stroustrup
C) Dennis Ritchie
D) Bill Gates
Explanation: Bjarne Stroustrup developed C++ as an extension of C.
29. C++ supports which programming paradigm?
A) Procedural only
B) Both procedural and object-oriented
C) Assembly
D) Modular only
Explanation: C++ supports multiple paradigms including object-oriented and procedural.
30. Which of the following is not a valid operator in C++?
A) +
B) :=
C) -
D) /
Explanation: := is not used in C++; it is used in languages like Pascal.
Chapter 3: Input/Output Handling in C++
1. Which header file is required for input and output operations in C++?
A) stdio.h
B) conio.h
C) iostream
D) math.h
Explanation: The iostream header file is used for input and output operations in C++.
2. What is the function used to display output in C++?
A) input()
B) scan()
C) cout
D) display()
Explanation: The cout function is used to output data to the screen.
3. What is the function used to take input from the user in C++?
A) output()
B) cin
C) scan()
D) get()
Explanation: The cin function is used to accept input from the user.
4. The << operator is used for:
A) Assignment
B) Output
C) Input
D) Arithmetic operations
Explanation: The << operator is the insertion operator used for output with cout.
5. The >> operator is used for:
A) Assignment
B) Input
C) Output
D) Data manipulation
Explanation: The >> operator is the extraction operator used with cin for input.
6. Which of the following is the correct way to display a string?
A) cout > "Hello World";
B) cout << "Hello World";
C) output << "Hello World";
D) cout - "Hello World";
Explanation: The << operator is used to send the output to cout.
7. Which of the following statements correctly reads an integer into the variable x?
A) cin << x;
B) cin >> x;
C) cin - x;
D) input >> x;
Explanation: The >> operator is used with cin to read input.
8. To insert a new line after the output, which command is used?
A) cout << endl();
B) cout << endl;
C) cout << "n";
D) cout << "newline";
Explanation: The endl manipulator is used to insert a new line and flush the output buffer.
9. What is the purpose of the flush function in C++?
A) To stop the program
B) To erase the output buffer
C) To add a new line
D) To flush the output buffer
Explanation: flush is used to flush the output buffer and ensure data is printed immediately.
10. Which function is used to clear the input buffer in C++?
A) clear()
B) [Link]()
C) flush()
D) [Link]()
Explanation: [Link]() is used to clear the input buffer.
11. Which of the following is the correct way to read a string in C++?
A) cin >> "string";
B) cin << "string";
C) cin >> string;
D) input >> string;
Explanation: cin >> is used to read a string or word, but spaces will be ignored.
12. The setw() function in C++ is used to:
A) Set the width of the output
B) Set the value of a variable
C) Display a value with a specific number of decimal places
D) Set the size of an array
Explanation: setw() sets the width for the next input/output operation.
13. What does the flush function do in the context of output?
A) Delays output
B) Clears the output buffer
C) Terminates the program
D) Moves to the next line
Explanation: flush is used to clear the output buffer, forcing immediate display.
14. Which of the following outputs the number 10 with width 5?
A) cout << setw(10) << 10;
B) cout << 10 << setw(5);
C) cout << setw(5) << 10;
D) cout << 10 << 5;
Explanation: setw(5) ensures the number is displayed with a total width of 5 characters.
15. Which of the following is used to handle input errors in C++?
A) [Link]()
B) error()
C) [Link]()
D) [Link]()
Explanation: [Link]() clears the error state flag on cin after an input error.
16. Which function can be used to ignore characters in the input stream?
A) [Link]()
B) [Link]()
C) [Link]();
D) [Link]()
Explanation: [Link]() is used to skip characters in the input stream.
17. How do you insert multiple spaces in the output in C++?
A) cout << "\t";
B) cout << " ";
C) cout << "\n";
D) cout << "/t";
Explanation: You can insert spaces by adding the space character " " in the output.
18. Which of the following outputs a string in uppercase?
A) cout << "HELLO";
B) cout << "hello".upper();
C) cout << setw("hello");
D) cout << "hello";
Explanation: You can manually convert a string to uppercase by manipulating the characters.
19. Which operator is used to concatenate strings in C++?
A) +
B) &
C) =
D) .
Explanation: The + operator is used to concatenate strings in C++.
20. How do you print a string on the next line?
A) cout << "\t";
B) cout << endl;
C) cout << " ";
D) cout << "\n";
Explanation: endl inserts a newline and flushes the buffer.
21. Which of these is used for formatted output in C++?
A) printf()
B) write()
C) cout with manipulators
D) show()
Explanation: cout with manipulators like setw(), setprecision(), etc., is used for formatted
output.
22. Which of the following is a C++ operator for formatted output?
A) %
B) <<
C) @
D) //
Explanation: << is used with cout to perform formatted output in C++.
23. What does the setprecision() function do in C++?
A) Sets the font size
B) Sets the number of decimal places for floating-point numbers
C) Sets the color of the output
D) Sets the width of the output
Explanation: setprecision() controls the number of digits displayed after the decimal point.
24. Which function is used to clear the output buffer?
A) clear()
B) reset()
C) flush()
D) buffer()
Explanation: The flush() function is used to clear the output buffer.
25. Which statement is used to handle an error in input operation?
A) [Link]()
B) [Link]()
C) error()
D) [Link]()
Explanation: [Link]() checks if the previous input operation failed.
26. What happens when the cin >> x; operation fails?
A) The program continues normally
B) The variable x gets the default value
C) The failbit is set
D) The program terminates
Explanation: When an error occurs during input, the failbit is set to indicate failure.
27. What is the default state of the failbit in C++?
A) Set
B) Clear
C) Ignored
D) Frozen
Explanation: The failbit is cleared by default when input operations are successful.
28. Which of the following clears the error state of cin?
A) [Link]()
B) [Link]()
C) [Link]()
D) reset()
Explanation: [Link]() clears any error flags (like failbit) from cin.
29. How would you print a floating-point number with 2 decimal places in C++?
A) cout << fixed << setprecision(2) << x;
B) cout << x << 2;
C) cout << fixed << setprecision(2) << x;
D) cout << "fixed(x)";
Explanation: setprecision(2) ensures the floating-point number is printed with 2 decimal
places.
30. The endl manipulator is used to:
A) Flush the output buffer
B) Set precision
C) Add a new line
D) Insert tabs
Explanation: endl adds a new line and flushes the output buffer.
Chapter 4: Control Structures
1. Control structures are used to:
A) Store data
B) Control the flow of program execution
C) Display output
D) Define variables
Explanation: Control structures manage the logical flow of instructions based on conditions or
loops.
2. How many types of basic control structures are there in C++?
A) 2
B) 3
C) 4
D) 5
Explanation: There are three basic control structures: sequence, selection, and repetition.
3. The default control structure in any program is:
A) Selection
B) Loop
C) Sequence
D) Function
Explanation: Sequence is the default structure where instructions are executed in order.
4. The if statement is a type of:
A) Loop
B) Sequence
C) Selection
D) Repetition
Explanation: if is a selection structure used for decision-making.
5. Which control structure is used to repeat a block of code?
A) if
B) switch
C) loop
D) return
Explanation: Looping structures like while, for, and do-while repeat code blocks.
6. In C++, which keyword is used for multiple decision control?
A) if
B) for
C) switch
D) goto
Explanation: switch is used for multi-way branching based on variable values.
7. What is the syntax of an if statement?
A) if (condition);
B) if condition {}
C) if (condition) { // code }
D) if = condition
Explanation: The correct syntax uses parentheses around the condition and curly braces for the
block.
8. The else statement is executed when:
A) The condition is true
B) The condition is false
C) The loop ends
D) A variable is zero
Explanation: else runs when the if condition is not satisfied.
9. The else if ladder is used when:
A) Only one condition is checked
B) Multiple conditions are checked
C) Loop is repeated
D) Input is taken
Explanation: else if helps check multiple exclusive conditions in a sequence.
10. A switch statement uses:
A) Boolean conditions
B) Constant expressions
C) Loops
D) Input functions
Explanation: Each case in a switch must use constant expressions.
11. A case block in a switch ends with:
A) break
B) break;
C) exit
D) stop
Explanation: The break; prevents fall-through in the switch structure.
12. If break is omitted in a switch case:
A) The program halts
B) Error is shown
C) Control flows to the next case
D) Case is skipped
Explanation: Without break, control moves into the next case block.
13. A loop that executes at least once is:
A) while
B) do-while
C) for
D) goto
Explanation: do-while executes the loop body before checking the condition.
14. In a for loop, the initialization is done:
A) At the end
B) At the beginning
C) Inside the body
D) Outside the loop
Explanation: Initialization is done before the first iteration.
15. Which loop checks the condition before executing the block?
A) do-while
B) while
C) goto
D) continue
Explanation: while checks the condition first; if false, the block isn't executed.
16. The syntax of a for loop is:
A) for i = 0; i < n; ++i
B) for (i < n; i++; i = 0)
C) for (int i = 0; i < n; i++)
D) for int i < n
Explanation: Proper syntax includes all three parts: initialization; condition; increment.
17. What will continue do in a loop?
A) Exit the loop
B) Skip current iteration
C) Stop program
D) Reset loop
Explanation: continue skips the current iteration and goes to the next.
18. The break statement in a loop:
A) Immediately exits the loop
B) Skips to the next iteration
C) Repeats the loop
D) Displays output
Explanation: break stops loop execution and exits immediately.
19. A loop that never ends is called:
A) complete loop
B) infinite loop
C) partial loop
D) final loop
Explanation: If the condition never becomes false, the loop runs infinitely.
20. Which keyword transfers control out of a loop?
A) skip
B) break
C) pass
D) exit
Explanation: break is used to exit from a loop prematurely.
21. In a while loop, the loop runs:
A) Until a break is found
B) As long as the condition is true
C) One time only
D) Even if condition is false
Explanation: A while loop continues as long as the condition remains true.
22. What happens if the condition in a while loop is false initially?
A) The loop runs once
B) The loop doesn't run at all
C) Error occurs
D) Skips one step
Explanation: The condition is checked first; if false, the loop body is skipped.
23. The keyword goto is used for:
A) Repeating blocks
B) Jumping to a labeled statement
C) Input handling
D) Loop increment
Explanation: goto causes the program to jump to a specified label.
24. The default label in switch is executed when:
A) No cases match
B) All cases match
C) First case matches
D) Last case matches
Explanation: If none of the cases match, the default block is executed.
25. Which loop is most suitable when the number of iterations is known?
A) while
B) for
C) do-while
D) if
Explanation: A for loop is best when the number of repetitions is known beforehand.
26. Nested control structures mean:
A) Functions inside functions
B) Control structures inside others
C) Variables within loops
D) Header files
Explanation: A nested structure places one control structure inside another (e.g., a loop inside
an if).
27. if (x == 10) checks if:
A) x equals 0
B) x equals 10
C) x is more than 10
D) x is not 10
Explanation: == is the comparison operator that checks equality.
28. What type of value does a condition return?
A) Integer
B) Float
C) Boolean
D) String
Explanation: Conditions return a boolean value — either true or false.
29. Which control structure ensures at least one execution?
A) while
B) for
C) do-while
D) if-else
Explanation: do-while runs the block once before checking the condition.
30. Control structures help to:
A) Declare variables
B) Manage program logic and decisions
C) Create new files
D) Compile programs
Explanation: They are used to control logic flow, decisions, and iterations in code.
Chapter 5: Functions
1. A function is a:
A) Variable
B) Data type
C) Block of code that performs a task
D) Constant
Explanation: A function is a named block of code designed to perform a specific task.
2. Which keyword is used to define a function in C++?
A) define
B) method
C) void/int/float/etc.
D) def
Explanation: In C++, functions are defined using return types like void, int, etc., followed by
the function name.
3. The function from where execution of a program begins is:
A) start()
B) run()
C) main()
D) execute()
Explanation: The main() function is the entry point of every C++ program.
4. A function that does not return a value is declared as:
A) int
B) void
C) char
D) null
Explanation: void indicates the function does not return any value.
5. A function can return how many values at a time?
A) 2
B) 1
C) Unlimited
D) None
Explanation: A C++ function can return only one value using the return statement.
6. Which of the following is NOT a part of a function definition?
A) Function name
B) Return type
C) Compiler version
D) Parameter list
Explanation: The compiler version is unrelated to function structure.
7. What are the inputs passed to a function called?
A) Returns
B) Parameters/Arguments
C) Constants
D) Blocks
Explanation: Inputs passed to functions are called parameters or arguments.
8. The variables defined inside a function are called:
A) Global variables
B) Constants
C) Local variables
D) Reference variables
Explanation: Variables inside a function are local and accessible only within that function.
9. The variables defined outside all functions are called:
A) Block variables
B) Global variables
C) Loop variables
D) Constants
Explanation: Global variables are declared outside all functions and are accessible anywhere in
the program.
10. A function with the same name but different parameters is an example of:
A) Recursion
B) Inheritance
C) Function overloading
D) Polymorphism
Explanation: Function overloading allows multiple functions with the same name but different
parameter lists.
11. Which keyword is used to return a value from a function?
A) give
B) send
C) return
D) stop
Explanation: The return keyword is used to send a value back to the calling function.
12. A function that calls itself is known as:
A) Loop function
B) Recursive function
C) Overloaded function
D) Main function
Explanation: Recursive functions are those that call themselves directly or indirectly.
13. What is the purpose of a function prototype?
A) To define logic
B) To declare a function before main()
C) To compile program
D) To debug code
Explanation: A function prototype tells the compiler about the function name, return type, and
parameters before its definition.
14. Function prototypes end with:
A) colon
B) comma
C) semicolon
D) bracket
Explanation: Like most declarations, prototypes end with a semicolon (;).
15. How many times can a function be called?
A) Once
B) Twice
C) As many times as needed
D) Only in main()
Explanation: Functions can be called multiple times from anywhere they are in scope.
16. What is the correct syntax for calling a function named sum()?
A) call sum;
B) run sum;
C) sum();
D) return sum();
Explanation: Functions are called by writing their name followed by parentheses, e.g., sum();.
17. What happens if a function is called but not defined?
A) It runs by default
B) Program works
C) Compiler error occurs
D) It skips
Explanation: If a called function isn't defined, the compiler throws an error.
18. A function that returns an integer must be declared as:
A) float
B) void
C) int
D) string
Explanation: To return integers, the return type must be int.
19. What type of values can functions return?
A) Only int
B) Only float
C) Any data type
D) Only string
Explanation: Functions can return values of any valid data type (int, float, char, etc.).
20. In C++, the main() function returns a value of type:
A) void
B) int
C) char
D) float
Explanation: By default, main() returns int in standard C++.
21. Which of the following is true about local variables?
A) They are accessible globally
B) They are declared outside functions
C) They are destroyed after function ends
D) They are permanent
Explanation: Local variables exist only during the function's execution.
22. What happens if a function has no return statement but is declared as int?
A) It returns zero
B) Compilation error may occur
C) It works normally
D) It gives output
Explanation: If an int function doesn’t return a value, it can lead to warnings or undefined
behavior.
23. A function that returns nothing is declared with:
A) null
B) none
C) void
D) int
Explanation: The keyword void specifies no value is returned.
24. Which of these is used to define a function body?
A) Parentheses
B) Square brackets
C) Curly braces
D) Colon
Explanation: The body of a function is enclosed in curly braces { }.
25. A function can have:
A) No parameter
B) One parameter
C) Multiple parameters
D) All of the above
Explanation: Functions can have no, one, or many parameters.
26. Which of the following is NOT a valid function name?
A) display
B) sum2
C) 2sum
D) average_result
Explanation: Function names cannot begin with a digit.
27. Which part of the function defines what it does?
A) Declaration
B) Call
C) Definition
D) Prototype
Explanation: The function definition includes the actual body — what the function does.
28. Which keyword is used to exit a function early?
A) break
B) exit
C) return
D) stop
Explanation: return exits the function and optionally passes a value back.
29. Why are functions used in programs?
A) To increase memory usage
B) To slow down the code
C) To reuse code and make it manageable
D) To replace loops
Explanation: Functions improve modularity and reusability in programs.
30. A function header includes:
A) Only return type
B) Return type, function name, parameter list
C) Only function body
D) Only variable declarations
Explanation: The header specifies return type, function name, and its parameters (if any).
Chapter 6: Digital Logic and Design
1. Digital systems work with:
A) Continuous signals
B) Electric waves
C) Discrete signals (0s and 1s)
D) Magnetic pulses
Explanation: Digital systems process binary data, which consists of discrete 0 and 1 signals.
2. Binary number system uses how many digits?
A) 3
B) 10
C) 2
D) 8
Explanation: The binary system only uses two digits: 0 and 1.
3. The base of the binary number system is:
A) 10
B) 8
C) 2
D) 16
Explanation: Binary is base-2, meaning it uses only two symbols (0 and 1).
4. 1 + 1 in binary equals:
A) 1
B) 10
C) 10 (binary for 2)
D) 11
Explanation: 1 + 1 = 10 in binary (which equals 2 in decimal).
5. Which logic gate gives HIGH output only when all inputs are HIGH?
A) OR
B) NOT
C) AND
D) XOR
Explanation: The AND gate outputs 1 only if all inputs are 1.
6. Which logic gate gives HIGH output if at least one input is HIGH?
A) OR
B) AND
C) NAND
D) NOR
Explanation: The OR gate gives 1 if any input is 1.
7. The NOT gate is also called:
A) Buffer
B) Flip-Flop
C) Inverter
D) Controller
Explanation: The NOT gate inverts the input: 1 becomes 0, and 0 becomes 1.
8. The output of a NOT gate when input is 1 is:
A) 1
B) 0
C) 10
D) Undefined
Explanation: NOT gate inverts 1 to 0.
9. The basic logic gates are:
A) NAND, NOR, XOR
B) AND, OR, NOT
C) NOT, XOR, XNOR
D) NOR, AND, NAND
Explanation: The three basic gates are AND, OR, and NOT.
10. Which gate is known as the universal gate?
A) XOR
B) OR
C) NAND
D) NOT
Explanation: NAND is a universal gate because it can be used to create any other logic gate.
11. The output of an AND gate with inputs 1 and 0 is:
A) 1
B) 0
C) 0
D) 10
Explanation: AND gate only gives 1 if both inputs are 1.
12. The output of an OR gate with inputs 0 and 0 is:
A) 1
B) 0
C) 10
D) Undefined
Explanation: OR gate gives 1 if at least one input is 1. If both are 0, output is 0.
13. What is the binary equivalent of decimal 5?
A) 1010
B) 1001
C) 101
D) 110
Explanation: 5 in decimal equals 101 in binary.
14. The decimal of binary 1101 is:
A) 13
B) 11
C) 13
D) 14
Explanation: 1101 in binary equals 13 in decimal.
15. Which number system uses digits 0 to 9 and A to F?
A) Binary
B) Octal
C) Hexadecimal
D) Decimal
Explanation: Hexadecimal uses base-16 with digits 0-9 and letters A-F.
16. The full form of ASCII is:
A) Advanced System for Coding Information
B) Algorithmic Scheme for Code Input
C) American Standard Code for Information Interchange
D) Automated Software Code Instruction
Explanation: ASCII is a coding standard for representing characters as numbers.
17. What is 1 + 1 + 1 in binary?
A) 10
B) 11
C) 11 (binary for 3)
D) 100
Explanation: 1 + 1 + 1 = 11 in binary.
18. Which gate outputs LOW only when all inputs are HIGH?
A) AND
B) OR
C) NAND
D) XOR
Explanation: NAND gate is the inverse of AND: it gives 0 only when all inputs are 1.
19. A truth table shows:
A) Diagrams
B) Input-output relationships of logic gates
C) Graphs
D) Circuits
Explanation: Truth tables list all possible inputs and corresponding outputs of logic gates.
20. Which of the following is not a binary number?
A) 1011
B) 1201
C) 0101
D) 1000
Explanation: Binary numbers only include 0s and 1s; 1201 includes a 2.
21. Which of the following converts decimal to binary?
A) OR gate
B) Binary conversion method
C) NAND gate
D) Multiplier
Explanation: Binary conversion uses division by 2 to convert decimal numbers.
22. What is the output of NOT (0)?
A) 0
B) 1
C) 10
D) Undefined
Explanation: NOT inverts 0 to 1.
23. The logic gate used to compare two binary digits is:
A) NAND
B) OR
C) XOR
D) NOT
Explanation: XOR gives 1 only when inputs are different — useful for comparison.
24. In binary, what is 1111 + 0001?
A) 1110
B) 1111
C) 10000
D) 11000
Explanation: 1111 (15) + 0001 (1) = 10000 (16) in binary.
25. Digital circuits are made of:
A) Microcontrollers
B) Logic gates
C) Memory units
D) Floppy disks
Explanation: Logic gates are the building blocks of digital circuits.
26. A half adder is used for:
A) Division
B) Addition of two bits
C) Subtraction
D) Comparison
Explanation: A half adder adds two single-bit binary numbers.
27. The output of XOR gate is true if:
A) Both inputs are 1
B) Inputs are different
C) Inputs are same
D) Input is 0
Explanation: XOR outputs 1 only when the two inputs differ.
28. How many possible input combinations exist for a 2-input gate?
A) 2
B) 3
C) 4
D) 5
Explanation: 2 inputs → 2² = 4 combinations: 00, 01, 10, 11.
29. Logic gates are implemented using:
A) Software
B) Sensors
C) Electronic circuits
D) Switches only
Explanation: Gates are built using electronic circuits like transistors.
30. Which logic gate provides the opposite output of OR?
A) XOR
B) NAND
C) NOR
D) AND
Explanation: NOR is the inverse of OR — it gives 1 only when all inputs are 0. Here are 30
MCQs from Chapter 7: Introduction to Scratch (Computer Science 10th Class STBB,
English Medium), with bolded correct answers and clear explanations, formatted cleanly
without lines between questions:
Chapter 7: Introduction to Scratch
1. Scratch is a:
A) Text-based language
B) Block-based visual programming language
C) Markup language
D) Hardware tool
Explanation: Scratch uses blocks to build programs visually, ideal for beginners and students.
2. Scratch was developed by:
A) Microsoft
B) MIT Media Lab
C) Apple
D) Google
Explanation: Scratch was developed by the MIT Media Lab to make programming accessible to
children.
3. In Scratch, the character that performs actions is called a:
A) Object
B) Player
C) Sprite
D) Icon
Explanation: A sprite is the main character or object that carries out tasks in a Scratch program.
4. The area where sprites move is called the:
A) Command line
B) Stage
C) Platform
D) Terminal
Explanation: The stage is the visual area where all sprite actions are displayed.
5. Scratch scripts are made using:
A) Syntax rules
B) Text commands
C) Blocks
D) Codes
Explanation: Scratch scripts are formed by snapping together colored blocks that represent
commands.
6. Each block in Scratch is a:
A) Program
B) Command line
C) Instruction or action
D) File
Explanation: Every block represents a specific instruction for the sprite.
7. Scratch projects are saved with the extension:
A) .exe
B) .scr
C) .sb or .sb3
D) .scratch
Explanation: Scratch files are saved as .sb, .sb2, or .sb3 depending on the version.
8. The green flag in Scratch is used to:
A) Stop the program
B) Save the script
C) Start the program
D) Open a new project
Explanation: Clicking the green flag starts the script from the beginning.
9. The red stop button is used to:
A) Run code
B) Stop all running scripts
C) Clear the stage
D) Refresh sprite
Explanation: The red stop button halts all ongoing actions in Scratch.
10. The command to repeat a set of instructions is:
A) move
B) turn
C) repeat
D) say
Explanation: The repeat block is used for loops, repeating instructions a set number of times.
11. Motion blocks are used to:
A) Paint sprites
B) Move sprites
C) Add sound
D) Delete code
Explanation: Motion blocks control the movement of sprites on the stage.
12. The Looks block category is used for:
A) Jumping
B) Changing sprite appearance or speaking
C) Making sound
D) Timing
Explanation: Looks blocks handle sprite appearances, speech, and visual effects.
13. The Sound block is used to:
A) Move sprite
B) Add or play sounds
C) Create background
D) Speak text
Explanation: The Sound block category lets users add and control audio playback.
14. The Pen block is used for:
A) Changing sprite
B) Drawing on the stage
C) Typing text
D) Zooming in
Explanation: Pen blocks allow sprites to draw lines and shapes on the stage.
15. Control blocks manage:
A) Size
B) Loops and conditions
C) Color
D) Costumes
Explanation: Control blocks manage the flow of scripts, like repetition and decisions.
16. Which block is used to make a decision?
A) move
B) repeat
C) if
D) glide
Explanation: The if block allows conditional execution of code.
17. A variable in Scratch is created to:
A) Change color
B) Store data
C) Draw shapes
D) Move sprite
Explanation: Variables in Scratch are used to store and change values during script execution.
18. The command to wait for a specified time is:
A) delay
B) wait
C) hold
D) freeze
Explanation: The wait block pauses the script for a specific duration.
19. Scratch supports:
A) Only sound
B) Animation, sound, and logic
C) Text only
D) Hardware control only
Explanation: Scratch combines sound, motion, control, and logic in an interactive way.
20. The backdrop in Scratch is:
A) A sprite
B) A sound
C) Background of the stage
D) Costume
Explanation: The backdrop is the background scenery displayed behind the sprites.
21. What is a script in Scratch?
A) A variable
B) A sprite
C) A group of connected blocks
D) A costume
Explanation: A script is a stack of blocks snapped together to control sprite behavior.
22. What is the purpose of the forever block?
A) Stop a script
B) Repeat actions continuously
C) Store variables
D) Clone a sprite
Explanation: The forever block repeats the contained actions endlessly.
23. In Scratch, a costume refers to:
A) A background
B) A voice
C) Appearance of a sprite
D) A drawing
Explanation: Costumes define how a sprite looks; a sprite can switch between multiple
costumes.
24. The sensing block is used to:
A) Move sprites
B) Detect conditions and interactions
C) Control timing
D) Make decisions
Explanation: Sensing blocks detect interactions, such as touching another sprite or key presses.
25. What does the "say" block do?
A) Play music
B) Makes the sprite display a speech bubble
C) Changes sound
D) Sends a message
Explanation: The say block makes the sprite show a message in a speech bubble.
26. Broadcasting in Scratch is used for:
A) Sound control
B) Loop creation
C) Sending messages between sprites
D) Drawing shapes
Explanation: broadcast sends a message that other sprites can respond to.
27. Which block waits until a message is received before executing?
A) say
B) forever
C) when I receive
D) control
Explanation: when I receive listens for a broadcast message to begin its script.
28. Which Scratch block can control time-based actions?
A) repeat
B) if
C) wait
D) glide
Explanation: The wait block is used to delay actions by seconds.
29. What kind of programming model does Scratch use?
A) Functional
B) Event-driven
C) Object-oriented
D) Procedural
Explanation: Scratch runs scripts in response to events like clicking the green flag or pressing a
key.
30. In Scratch, events begin with:
A) say block
B) repeat block
C) hat blocks like “when green flag clicked”
D) costume changes
Explanation: Hat blocks (top of a stack) start scripts in response to events.