wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Long Quiz

Total questions: 60

Worksheet time: 36mins

Name
Class
Date
1.
  1. Who developed C++?

a)
  1. Dennis Ritchie

b)
  1. James Gosling

c)
  1. Guido van Rossum

d)
  1. Bjarne Stroustrup

2.

What was the original name of C++?

a)
  1. C with Classes

b)
  1. Advanced C

c)
  1. Object-C

d)
  1. Super C

3.

Which of the following is a performance-oriented programming language?

a)

Python

b)

JavaScript

c)
  1. C++

d)

C

4.

Which of the following is a commonly used IDE for C++?

a)

Eclipse

b)

NetBeans

c)
  1. Code::Blocks

d)
  1. Android Studio

5.

In a C++ program, which line includes the standard input/output library?

a)
  1. #include <iostream>

b)
  1. #include <stdio.h>

c)
  1. #include <stdlib.h>

d)
  1. #include <inputoutput>

6.

What is the entry point of every C++ program?

a)
  1. start()

b)
  1. program()

c)
  1. main()

d)
  1. begin()

7.

Which keyword is used to declare a variable that stores whole numbers?

a)

string

b)

float

c)

int

d)

bool

8.

Which of the following stores decimal values with higher precision?

a)

char

b)

int

c)

float

d)

double

9.

Which symbol is used with cout to display output?

a)

>>

b)

::

c)

<<

d)

;

10.

Which symbol is used with cin to accept input?

a)

>>

b)

<<

c)

==

d)

;

11.

What will be the output of the following code?

a)

2

b)

2.5

c)

5/2

d)

Error

12.

Which operator is used to get the remainder of a division?

a)

/

b)

*

c)

%

d)

#

13.

Which of the following correctly declares a string variable?

a)
  1. string name = "John";

b)
  1. string name = 'John';

c)
  1. String name = ‘John’;

d)
  1. String name = "John";

14.

Which data type can only hold true/false values?

a)

string

b)

bool

c)

int

d)

double

15.

Which of the following statements will correctly display "Hello World"?

a)

cout << "Hello World";

b)

cin << "Hello World";

c)

cout >> "Hello World";

d)

cin >> "Hello World";

16.

Which IDE is lightweight and often recommended for beginners in C++?

a)

Visual Studio

b)

Xcode

c)
  1. Dev-C++

d)

NetBeans

17.

What does return 0; represent in the main function?

a)

The program repeats

b)
  1. The program ended successfully

c)
  1. An error occurred

d)
  1. The program is paused

18.

Which of the following is NOT a basic data type in C++?

a)

int

b)

string

c)

bool

d)

array

19.

Which arithmetic operator is used for multiplication?

a)

+

b)

-

c)

/

d)

*

20.

What is the output of this code?

a)

2

b)

2.5

c)

1

d)

3

21.

Which statement is used to make decisions in C++?

a)

loop

b)

if

c)

switch

d)

break

22.

In an if statement, what happens if the condition is false?

a)
  1. The program crashes

b)
  1. The condition becomes true automatically

c)
  1. The block inside runs anyway

d)
  1. The block is skipped

23.

Which symbol is used for equality comparison in C++?

a)

=

b)

&&

c)

==

d)

===

24.

Which control structure is best for checking multiple constant values of one variable?

a)
  1. if-else

b)
  1. for loop

c)
  1. while loop

d)
  1. switch-case

25.

What keyword is used to exit a loop immediately?

a)

exit

b)

skip

c)
  1. break

d)

continue

26.

What does the continue statement do?

a)
  1. Stops the program

b)
  1. Skips the current iteration and moves to the next

c)
  1. Exits the loop completely

d)
  1. Repeats the last iteration

27.

Which loop guarantees execution of the block at least once?

a)

while

b)

for

c)
  1. do-while

d)
  1. repeat

28.

Which part of a for loop runs first?

a)

condition

b)

update

c)
  1. initialization

d)
  1. statement block

29.

Which loop is best when the number of iterations is known?

a)

while

b)
  1. do-while

c)

for

d)
  1. if-else

30.

What will this code output?

a)

A

b)

B

c)

Nothing

d)

Error

31.

In nested loops, the inner loop runs…

a)
  1. Only once

b)
  1. Completely for every outer loop iteration

c)
  1. Only if the outer loop is finished

d)
  1. Randomly

32.

What is the default case in a switch used for?

a)
  1. When no other cases match

b)
  1. To reset the loop

c)
  1. To skip input

d)
  1. To initialize variables

33.

What will happen in a while loop if the condition never becomes false?

a)
  1. The loop stops

b)
  1. It becomes infinite

c)
  1. Error occurs

d)
  1. Runs once only

34.

Which logical operator means “AND”?

a)

||

b)
  1. &&

c)

!

d)
  1. %

35.

What is printed?

a)
  1. 1 2 3

b)
  1. 0 1 2

c)
  1. 2 3 4

d)
  1. 1 2 3 4

36.

Which is NOT a loop in C++?

a)

while

b)
  1. do-while

c)
  1. repeat-until

d)
  1. if-else

37.

Which is true about if-else if ladder?

a)
  1. Executes all blocks

b)
  1. Executes the first true block and skips the rest

c)
  1. Always executes the last block

d)
  1. Skips all blocks

38.

Which keyword is used inside switch cases?

a)

stop

b)

end

c)

break

d)

return

39.

Which type of values can switch-case handle in C++ (by default)?

a)
  1. int, char, enum

b)
  1. float, double

c)

string

d)
  1. boolean only

40.

What is the output?

a)
  1. Nothing

b)
  1. Infinite loop

c)

Error

d)

1

41.

Which of the following best defines a function in C++?

a)
  1. A variable storing data

b)
  1. A block of code performing a task

c)
  1. A reusable unit of code with a name

d)
  1. A type of loop

42.

What is the correct syntax to declare a function prototype that returns an integer?

a)
  1. int function();

b)
  1. int function;

c)
  1. int function(int a, int b);

d)
  1. int(function);

43.

Which keyword is used to send a value back from a function?

a)

send

b)

return

c)
  1. break

d)

exit

44.

Passing a parameter by value means:

a)
  1. The function gets direct access to the original variable

b)
  1. The function stores the memory address

c)
  1. The function cannot use the variable

d)
  1. A copy of the value is passed

45.

What happens if a function is declared but never defined?

a)
  1. It still works fine

b)
  1. It causes a linker error

c)
  1. It returns 0 by default

d)
  1. It is ignored by the compiler

46.

Which function call is correct if the prototype is double avg(int x, int y);?

a)
  1. avg();

b)
  1. avg(4, 5);

c)
  1. avg(4.5, 5.2);

d)
  1. avg(4)

47.

In C++, the main() function must always return which type?

a)

void

b)

int

c)
  1. float

d)

char

48.

Which of these is an example of a library function?

a)
  1. myFunction()

b)
  1. add()

c)
  1. average()

d)
  1. sqrt()

49.

Which of the following errors is detected at compile time?

a)
  1. Syntax error

b)
  1. Logical error

c)
  1. Runtime error

d)
  1. Infinite loop

50.

Which error type occurs when dividing by zero?

a)
  1. Syntax error

b)
  1. Logical error

c)
  1. Runtime error

d)
  1. Semantic error

51.

Debugging is mainly the process of:

a)
  1. Writing new code

b)
  1. Finding and fixing bugs

c)
  1. Removing comments

d)
  1. Adding libraries

52.

A missing semicolon will cause:

a)
  1. Syntax error

b)
  1. Logical error

c)
  1. Runtime error

d)
  1. Compiler warning only

53.

A wrong formula implementation is an example of:

a)
  1. Syntax error

b)
  1. Logical error

c)
  1. Runtime error

d)
  1. Semantic error

54.

Which tool in IDE is used to pause code at a specific line?

a)
  1. Breakpoint

b)
  1. Step over

c)
  1. Step into

d)
  1. Watch variable

55.

Which debugging tool allows tracking how a variable changes during execution?

a)

Breakpoint

b)
  1. Watch variable

c)
  1. Step into

d)
  1. Output console

56.

Which debugging option executes function calls without entering inside them?

a)

Breakpoint

b)
  1. Step over

c)
  1. Step into

d)
  1. Watch variable

57.

Which debugging option follows the code line by line into functions?

a)
  1. Breakpoint

b)
  1. Step over

c)
  1. Step into

d)
  1. Watch variable

58.

Where are error messages usually displayed in an IDE?

a)
  1. Code editor

b)
  1. Title bar

c)
  1. Output window / Console

d)
  1. Header files

59.

Which is a best practice in debugging?

a)
  1. Ignore compiler errors

b)
  1. Use single-letter variable names

c)
  1. Test small parts of code first

d)
  1. Write entire program before testing

60.

Why are print statements sometimes used during debugging?

a)
  1. To make output colorful

b)
  1. To trace execution flow and variable values

c)
  1. To speed up the program

d)
  1. To replace breakpoints