wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

с+++

Total questions: 56

Worksheet time: 28mins

Name
Class
Date
1.

Which of the following is the output from the following C++ code?

a)

15

b)

15 14 13 12 11 10

c)

15 14 13 12 11 10 9

d)

9

2.

If originally x=0, y=1, and z=3, what is the value of x, y, and z afterexecuting the following code ?

a)

x=0 y=3 z=3

b)


x=0 y=1 z=3

c)

x=3 y=3 z=3

d)

x=3 y=1 z=0

3.

What is the value of x after the following statements?

a)

10

b)

33

c)

3

d)

0

4.

What is the value of x after the following statements?              

a)

15

b)

4

c)

3

d)

0

5.

Which of the following is the output from the following C++?      

a)

5

b)

0

c)

4

d)

6

6.

Given the following code fragment, what is the final value of y?  

a)

2

b)

8

c)

4

d)

3

7.

Which of the following is the output from the following C++ code  

a)

10

b)

12

c)

3

d)

4

8.

Which of the following is the output from the following C++ code?    

a)

6

b)

0

c)

4

d)

5

9.

Which of the following is the final value of y from the following C++

a)

2

b)

3

c)

22

d)

0

10.

Which of the following is the final value of ‘i’ from the following C++ code ?

a)

4

b)

5

c)

0 1 2 3 4

d)

0 1 2 3 4 5

11.

What is the value of x after the following code executes?  

a)

10

b)

11

c)

13

d)

0

12.

Given the following code, what is the final value of i?

a)

2

b)

4

c)

3

d)

0

13.

What is the value of x after the following code executes?  

a)

10

b)

11

c)

13

d)

0

14.

What is the output of the following code segment?      

a)

15

b)

25

c)

5

d)

0

15.

What does the following code print to the screen?  

a)

7

b)

cout

c)

int

d)

world

16.

What is the value of x after the following statements?                    

a)

15

b)

10

c)

5

d)

25

17.

What is the value of x after the following statements?      

a)

25

b)

4

c)

5

d)

1

18.

What is the value of x after the following code executes?

a)

10

b)

11

c)

23

d)

13

19.

Given the following code, what is the final value of i?

a)

4

b)

6

c)

5

d)

0

20.

Given the following code, what is the final value of i?

a)

4

b)

6

c)

5

d)

0

21.

Which of the following is the valid array declaration

a)

int num(5)

b)

int mycat[5]

c)

Array. double[5] marks

d)

Myarray.counter int[5]

22.

What is the output of the following code?  

a)

7

b)

Value

c)

1

d)

6

23.

What is the output of the following code?  

a)

11

b)

10

c)

0

d)

12

24.

What is the final output of the following code fragment?        

a)

22

b)

23

c)

20

d)

0

25.

. Solve the following piece of code and choose the best answer

a)

The function addition is called by passing the values

b)

The function addition is called by passing reference

c)

Both of abovе

d)

None of above


26.

If the type specifies of parameters of a function is followed by anampersand &, that function call is…

a)

Pass by value

b)

Pass by reference

c)

All of answers

d)

None of answers

27.

Which of the following gives the memory address of a pointer pt1?

a)

*pt1;

b)

pt1;

c)

&pt1;

d)

address(prt1);

28.

What is the value of x after the following statement

a)

1,75

b)

50

c)

30

d)

20

29.

What is the final value of x after the following fragment of codeexecutes ?

a)

Infinite loop

b)

1

c)

Never

d)

0

30.

What is the value of x after the following statement

a)

3,75

b)

1,75

c)

2

d)

0

31.

What is the value of x after the following statements?

a)

7

b)

10

c)

3

d)

33

32.

What is the value of x after the following statements?        

a)

70

b)

30

c)

3

d)

33

33.

Given the following code fragment, what is the output

a)

5

b)

Thats is all. Goodbye

c)

X bigger than 5

d)

X

34.

How many times is "Hi" printed to the screen?

a)

0

b)

1

c)

14

d)

15

35.

There is given array with n elements, created as pointer. How toremove it correctly

a)

delete a;

b)

delete[] a;

c)

remove[] a;

d)

remove a;

36.

How to write correct recursive function for making sum of nnumbers?

a)

This

b)

This

c)

This

d)

This

37.

How to make several items in structure? Just think that you have“HOME”, and n items in it

a)

This

b)

This

c)

This

d)

This

38.

Find mistake of next cod?      

a)

Mistake in opening file, should be: file.open(“input.txt”);


b)

It should write in other file; it can’t write directly to command line

c)

No mistakes, it will just read from file and print first string in command line

d)

It should read from read from file, when we want to write in command line.


39.

What will print in command line next code?

a)

Read first string from file “input.txt”, and print it in command line.

b)

It will give an error, because, file should read in this way: file.open(“input.txt”);

c)

It won’t print anything.

d)

Read all lines and print it in new file.

40.

Which libraries should be included to get string in a file?

a)

<string> and <fstream>

b)

<string> is enough

c)

<fstream>is enough

d)

<string> or  <fstream>


41.

Which one will be correct function for ?

a)

This

b)

This

c)

This

d)

This

42.

There are given array “numbers” with 10 numbers. How to makesum of all numbers, which are located in odd indexes?

a)

This

b)

This

c)

This

d)

This

43.

There is given string named “str”. How to print in command linelength of str?

a)

cout << str.count();

b)

cout << str.length;

c)

cout << str.lenth();

d)

cout >> str.lenth();

44.

How to implement array of chars with 10 elements?

a)

char* chs; chs = new char(10);

b)

char chs; chs = char[10];

c)

char chs[10];

d)

char chs[] = new char[10];

45.

How to implement array of integer numbers with n elements, andhow to delete them correctly?

a)

int n; cin >> n; int* a; a = new% int[n]; delete[] a;

b)

int n; cin >> n; int& a; a = new int[n]; delete[] a;

c)

int n; cin >> n; int* a; a = new& int[n]; for(int

d)

i=0; i<n; i++) delete a;

46.

i=0; i<n; i++) delete a;

a)

string s; getline(cin, s);

b)

string s; getline(cout, s);

c)

string s; cin >> s;

d)

string s; cout << s;

47.

How to get whole string in one line (in file)?

a)

ifstream file; string s; getline(file, s);

b)

ifstream file; string s; getline(cin, s);

c)

ifstream file; string s; getline(cout, s);

d)

ifstream file; string s; file >> s;

48.

Why do we need library <fstream>?

a)

To work with strings

b)

To work with files.

c)

To work with mathematical functions.

d)

To work with our own libraries.

49.

Why do we need library <cmath>?

a)

To work with strings.

b)

To work with mathematical functions.

c)

To work with command line.

d)

To work with our own libraries.

50.

Where is the mistake of the code?

a)

Variable “a” do not have any values.

b)

Library <cmath> didn’t included.

c)

Library <math.h> didn’t included.

d)

Library <fstream> didn’t included.

51.

What will be printed in the part of the cod?

a)

1 4 7 10

b)

0 3 6 9

c)

3 6 9

d)

9 6 3 0

52.

What will be printed in the part of the code?

a)

0 8 16 24 32

b)

2 10 18 26 34

c)

6 12 20 28 36

d)

4 10 18 26 34

53.

Which of the following is the proper keyword to allocate memory?

a)

new

b)

malloc

c)

create

d)

value

54.

Which of the following is the proper keyword to deallocate memory?

a)

free

b)

delete

c)

clear

d)

remove

55.

Assume if A = 10; and B = 15; with using bitwise OR operator Find A||B

a)

10

b)

15

c)

61

d)

13

56.

"a"  in  line //1 equal  to ?

a)

1

b)

-1

c)

0

d)

Error