wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz1

Total questions: 15

Worksheet time: 21mins

Name
Class
Date
1.

Which of the following is not a valid C++ data type?

a)

int

b)

float

c)

real

d)

bool

2.

Which of the following is a valid C++ keyword?

a)

variable

b)

method

c)

function

d)

class

3.

What is the size of a char data type in C++?

a)

8 bytes

b)

1 byte

c)

2 bytes

d)

4 bytes

4.

Which of the following operators is used for logical AND in C++?

a)

==

b)

!

c)

||

d)

&&

5.

What is the default return type of a function in C++ if not specified?

a)

void

b)

int

c)

float

d)

double

6.

What will be the output?

a)

10 20

b)

15 30

c)

15 20

d)

Error

7.

Predict the output:

a)

10 10

b)

10 0

c)

0 0

d)

Compiler Error

8.

You are designing a bank account system. Which of the following should be modeled as a class with objects in C++?

a)

Interest rate calculations

b)

Each customer account

c)

Printing a statement

d)

Inputting customer details

9.

In recursion, which condition must always be present to avoid infinite calls?

a)

Function overloading

b)

Base case

c)

Destructor

d)

Polymorphism

10.

Which of the following is used to include standard libraries in a C++ program?

a)

require

b)

#include

c)

import

d)

using

11.

Write a C++ program to check whether a given number is prime using a function.

4 lines
12.

Define a Student class with attributes name, rollNo, and marks. Write a function to display the details of a student.

4 lines
13.

Which operator cannot be overloaded in C++?

a)

+

b)

=

c)

::

d)

[]

14.

Which of the following is not a valid identifier in C++?

a)

marks

b)

_total

c)

2value

d)

value2

15.

Write a function in C++ to compute the sum of digits of a number using recursion.

4 lines