wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C++ Basics

Total questions: 40

Worksheet time: 20mins

Name
Class
Date
1.

What is the only function that all C++ programs must contain?

a)

start()

b)

system()

c)

main()

d)

program()

2.

Which command in C++ moves the text to the next line?

a)

\t

b)

\n

c)

\r

d)

\s

3.

C++ was developed by?

a)
b)
c)
d)
4.

What is the extension of C++ programs?

a)

.c

b)

.css

c)

.cpp

d)

.jsp

5.

Which syntax is correct in printing an output in a C++ program?

a)

print<<"Good Day!";

b)

cout<<"Good Day!";

c)

printf<<"Good Day!";

d)

cout<<"Good"<<"Day!";

6.

Insertion operator (<<) is used with?

a)

cin

b)

cout

c)

both of the above

d)

main

7.

Which operators are used in C++?

a)

==

b)

+=

c)

**

d)

++

8.

Boolean variable is declared with (a)   keyword

9.

break() is used along which statements

a)

while

b)

switch

c)

for-while

d)

if-then-else

10.

I liked the quiz?

a)

Yes

b)

No

c)

Maybe

11.

Any suggestions?

4 lines
12.

This is a code that has not yet been linked into a complete program.

a)

Source Code

b)

Assembly Code

c)

Object Code

d)

Machine Code

13.

The object code is produced in what program development phase?

a)

Preprocessing

b)

Compilation

c)

Linking

d)

Loading

e)

Executing

14.

What happens first when a C++ executable is run?

a)

The preprocessor converts the source code into an object code.

b)

The compiler converts the object code into an executable code.

c)

The linker links the object code with the missing functions needed to produce the executable code.

d)

The loader places the program in the memory

e)

The CPU executes the program

15.

By default, how are instructions executed by the CPU?

a)

One instruction a a time

b)

Several Instructions at a time

c)

All instructions in one time

d)

None of the above

16.

Single line comments are denoted by what symbol?

a)

//

b)

\\

c)

/*

d)

*/

17.

Which of the following are ignored by the C++ compiler and the computer? Check all that applies.

a)

Comments

b)

Blank lines

c)

Spaces

d)

Tab Spaces

e)

Preprocessing directives

18.

A preprocessing directive starts with what symbol?

a)

//

b)

#

c)

(

d)

{

19.

The library defined in the preprocessor directive must be enclosed by what symbols?

a)

{ }

b)

[ ]

c)

< >

d)

( )

20.

Blanks lines, spaces, and tab characters are called?

a)

Keywords

b)

White spaces

c)

Symbols

d)

Escape Sequences

21.

A code that is reserved by C++ for a specific use.

a)

Keyword

b)

White space

c)

Symbol

d)

Escape Sequence

22.

Which symbol starts a block of code?

a)

<

b)

(

c)

{

d)

[

23.

The words enclosed in double quotation marks are known as the following EXCEPT what?

a)

String

b)

Character String

c)

String Literal

d)

Stream

24.

The semicolon (;) is used to?

a)

Start a block of code

b)

Terminate a function

c)

Start a statement

d)

End a statement

25.

Which of the following is the scope resolution operator?

a)

<<

b)

>>

c)

::

d)

\

26.

Which of the following is the escape character operator?

a)

<<

b)

>>

c)

::

d)

\

27.

Which of the following is the input stream object?

a)

>>

b)

<<

c)

cin

d)

cout

28.

Which of the following is NOT a VALID identifier?

a)

X1

b)

_X1

c)

x1

d)

_1x

e)

1x

29.

Which of the following are VALID identifiers?

a)

int

b)

include

c)

return

d)

zero

30.

All variables must be declared before they are used.

a)

True

b)

False

31.
The process of creating a new variable without value
a)
declaration
b)
naming
c)
instantiation
d)
assigning
32.

What does <= mean?

a)

less than

b)

greater than

c)

less than or equal to

d)

greater than or equal to

33.

What punctuation is used to signal the beginning and end of code blocks?

a)

{ }

b)

-> and <-

c)

BEGIN and END

d)

( and )

34.

Which of the following is a correct comment?

a)

*/ Comments */

b)

** Comment **

c)

/* Comment */

d)

{ Comment }

35.
After running the following code, what will be the value of x?
y = 3;
x = 5 * y;
a)
3
b)
5
c)
15
d)
0
36.
A programmer is:
a)
person who writes code and communicates instructions to a computer
b)
person who types
c)
person who studies computers
d)
error or mistake in your code
37.
What is the output of this program?
Program
int main()
{
cout<<"Hi everybody";
return 0;
}
a)
"Hi everybody"
b)
Hi everybody"
c)
Hi everybody
d)
"Hi everybody
38.

Which of the following is NOT a logical operator in C++ language?

a)

&

b)

&&

c)

||

d)

!

39.

Which of the following is NOT a comparison operator in C++ language?

a)

>

b)

<=

c)

=

d)

==

40.

If originally x=2,y=0, and z=1, what is the value of x, y, and z after executing the following code?


if (x>y)


y=x;

else

z=x;

a)

x=2 y=2 z=1

b)

x=0 y=2 z=0

c)

x=2 y=1 z=1

d)

x=2 y=0 z=1