Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C++ Chapter 2

Total questions: 7

Worksheet time: 4mins

Name
Class
Date
1.

What is the difference between the following two lines of code:


cout << "perimeter"; //LINE 1

cout << perimeter; //LINE 2

a)

LINE 1 prints out the actual word perimeter and LINE 2 prints out the value held in the variable: perimeter.

b)

LINE 2 prints out the actual word perimeter and LINE 1 prints out the value held in the variable: perimeter.

c)

You do not need a semi-colon at the end of the two lines.

d)

The lines are identical.

2.

Which of the following statements will read in THREE values from standard input (user typing it in) into variables named num1, num2, and num3 .

a)

cin>>num1>>num2>>num3;

b)

cin>>num1>>num2>>num3>>endl;

c)

cout<<num1<<num2<<num3<<endl;

d)

cin>>number1>>number2>>number3;

3.

(True or False) The following two snippets of code have the same result.

cin >> x >> y;

cin >> x;

cin >> y;

a)

True

b)

False

4.

Which of the following is an INVALID identifier?

a)

1stplace

b)

_firstplace

c)

firstPlace

d)

place1

5.

Which of these data types requires the least amount of memory?

a)

short

b)

double

c)

int

d)

float

6.

To declare and initialize 3.14159 to a constant PI, which of the following is the correct syntax?

a)

const PI = 3.14159;

b)

const double 3.14159 = PI;

c)

const double PI = 3.14159;

d)

const int PI = 3.14159;

7.

(T or F) The software development life cycle is a multi-stage process that includes the following items (in the following order):

* requirements specification

* system analysis

* system design

* implementation testing

* deployment

* maintenance

a)

True

b)

False