CPA –Programming Essentials in C++ Chapter 1 Module 1

 Question 1:

What is the value of the i variable? float x = 1.0 / 4.0; int i = x;

Answer:

0

Question 2:

Which of the following strings is a proper floating-point number (in the C++ language sense)?

Answer:

3.14

Question 3:

What is the output of the following snippet if a digit 5 followed by Enter is entered through the keyboard?

Answer:

10-125

Question 4:

What is the final value of the k variable?

int i = 3, j, k;

Answer:

2

Question 5:

Which of the following strings is a correct integer number (in the C++ language sense)?

Answer:

3'14

Question 6:

What is the value of the k variable? int i = 1; int j = ++i; int k = j++;

Answer:

2

Question 7:

Which of the following strings does not represent a valid variable name?

Answer:

auto

Question 8:

What is the value of the following literal?

0x1A
Answer:

26

Question 9:

What is the value of the following literal?

0E1
Answer:

0

Question 10:

What is the value of the x variable?

float x = 1. / 2. + 2. / 4.;

Answer:

1.0

Question 11:

What is the value of the k variable?

int k = 1 % 2 + 4 % 2;

Answer:

1

Question 12:

Which of the following strings represents a legal variable name?

Answer:

first_literal_is_invalid

Question 13:

What is the output of the following snippet if a digit 8 followed by Enter is entered through the keyboard?

Answer:

81010

Question 14:

What is the value of the following literal?

X10

Answer:

The literal is invalid.

Question 15:

What is the final value of the k variable?

int i = 3, j = 2, k = -1;

Answer:

5

Question 16:

What is the value of the following literal?

-1e-1

Answer:

-0.1

Question 17:

What is the output of the following snippet if a string 2.5 followed by Enter is entered through the keyboard?

Answer:

X

Question 18:

What is the output of the following snippet?

   int i = 3, j = ++i, k = ++i;

Answer:

545

Question 19:

What is the value of the following literal?

010

Answer:

8

Question 20:

What is the value of the following literal?

018

Answer:

The literal is invalid.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.