Topic 2 Variables

Question 1

Correct2.50 points out of 2.50Flag question

Question text

What is the output of the following code?

int main() {

   double y = 7 / 2;

   cout << y;

   return 0;

}Select one:a. 0b. 3 

Correct

c. 3.5d. No output. Error in code.

Feedback

The correct answer is: 3

Question 2

Correct2.50 points out of 2.50Flag question

Question text

Which statement contains a syntax error?

int main () {

   int day;

   cout << “Please enter which day of the month it is: “; // A)

   cin >> day // B)

   cout << “There are “ << 31 – day << “ days left until next month.”; // C)

   return 0;

}Select one:a. cout << “Please enter which day of the month it is: “;b. cin >> day 

Correct

c. cout << “There are “ << 31 – day << “ days left until next month.”;d. No errors.

Feedback

The correct answer is: cin >> day

Question 3

Correct2.50 points out of 2.50Flag question

Question text

What is the output of the following code?

int main() {

   int x = 5;  int y = 6;  int z = 2;

   x = x + y;

   z = x – 2;

   cout << z;

   return 0;

}Select one:a. 2b. 5c. 11d. 9 

Correct

Feedback

The correct answer is: 9

Question 4

Correct2.50 points out of 2.50Flag question

Question text

What is an application in computing?Select one:a. Translates a high-level language program into low-level machine instructions.b. Another word for program. 

Correct

c. Human-readable processor instructions; an assembler translates to machine instructions (0s and 1s).d. A series of 0s and 1s, stored in memory, that tells a processor to carry out a particular operation like multiplication.

Feedback

The correct answer is: Another word for program.

Question 5

Correct2.50 points out of 2.50Flag question

Question text

Which of the following is a valid identifier?Select one:a. 2usdb. usd$_perCapitac. usd perCapitad. _trainENG 

Correct

Feedback

The correct answer is: _trainENG

Question 6

Incorrect0.00 points out of 2.50Flag question

Question text

Which is the first statement to contain an overflow?

int main() {

   int x = 1000;  int y = 10000; // A)

   x = x * x; // B)

   y = x * x * y; // C)

   return 0;

}Select one:a. int x = 1000;  int y = 10000;b. x = x * y;c. y = x * x * y;d. No statement contains an overflow. 

Correct

Feedback

The correct answer is: No statement contains an overflow.

Question 7

Correct2.50 points out of 2.50Flag question

Question text

What does a statement of code do?Select one:a. Used to denote a list of statements.b. The starting place of a program.c. Tells the compiler or processor to perform a specific action. 

Correct

d. Textual representation of a program.

Feedback

The correct answer is: Tells the compiler or processor to perform a specific action.

Question 8

Correct2.50 points out of 2.50Flag question

Question text

What is the output of the following code if the code output 19574 in the previous run?

int main() {

   srand(50);

   cout << rand();

   return 0;

}Select one:a. 19574 

Correct

b. 19575c. 19584d. Cannot determine.

Feedback

The correct answer is: 19574

Question 9

Correct2.50 points out of 2.50Flag question

Question text

Which of the following statements may generate a warning?

int main() {

   int x = 1;  int y = 12;

   x = x + 3; // A)

   y = y – 1; // B)

   cout << (x / y); // C)

   return 0;

}Select one:a. x = x + 3;b. y = y – 1;c. cout << (x / y);d. None of the above. 

Correct

Feedback

The correct answer is: None of the above.

Question 10

Correct2.50 points out of 2.50Flag question

Question text

What is the output of the following code?

int main() {

   int y = 4;  int z = 2;

   cout << y * z – 2;

   return 0;

}Select one:a. 0b. 4c. 6 

Correct

d. No output. Error in code

Feedback

The correct answer is: 6

Question 11

Correct2.50 points out of 2.50Flag question

Question text

What is the output of the following code?

int main() {

   double x = 2.0; double y = 3.0;

   cout << pow(x, y);

   return 0;

}Select one:a. 5b. 6c. 8 

Correct

d. 9

Feedback

The correct answer is: 8

Question 12

Correct2.50 points out of 2.50Flag question

Question text

Which line of code produces the following output:

Enter an integer:Select one:a. cout << “Enter an integer:”; 

Correct

b. output << “Enter an integer:”;c. cout << ‘Enter an integer:’;d. print << ‘Enter an integer:’;

Feedback

The correct answer is: cout << “Enter an integer:”;

Question 13

Correct2.50 points out of 2.50Flag question

Question text

Which of the following statements declares a floating-point variable?Select one:a. float tempKelvin; 

Correct

b. floating tempKelvin;c. doublefloat tempKelvin;d. doubles tempKelvin;

Feedback

The correct answer is: float tempKelvin;

Question 14

Correct2.50 points out of 2.50Flag question

Question text

Which line of code contains a syntax error?int main() {

   string usrName; // A)

   char usrOption; // B)

   usrName = “Travis Jones”; // C)

   usrOption = “a”; // D)

   // main code

   return 0;

}Select one:a. string usrName;b. char usrOption;c. usrName = “Travis Jones”;d. usrOption = “a”; 

Correct

Feedback

The correct answer is: usrOption = “a”;

Question 15

Correct2.50 points out of 2.50Flag question

Question text

Convert the binary number 00100111 to decimal:Select one:a. 39 

Correct

b. 38c. 33d. 31

Feedback

The correct answer is: 39

Question 16

Correct2.50 points out of 2.50Flag question

Question text

What is the output of the following program when the user inputs “Travis Jones”?int main() {

   string usrStr = “”;

   cin >> usrStr;

   cout << usrStr;

   return 0;

}Select one:a. Travis 

Correct

b. Travis Jonesc. Jonesd. No output. Error occurs.

Feedback

The correct answer is: Travis

Question 17

Correct2.50 points out of 2.50Flag question

Question text

Which statement would store a user-entered number into a variable named numQuiz?Select one:a. cin >> numQuizb. cin << numQuiz;c. cout << numQuiz;d. cin >> numQuiz; 

Correct

Feedback

The correct answer is: cin >> numQuiz;

Question 18

Correct2.50 points out of 2.50Flag question

Question text

What is an operating system in a computer?Select one:a. The doubling of IC capacity roughly every 18 months.b. Non-volatile storage with slower access.c. Manages programs and interfaces with peripherals. 

Correct

d. Volatile storage with faster access usually located off processor chip.

Feedback

The correct answer is: Manages programs and interfaces with peripherals.

Question 19

Correct2.50 points out of 2.50Flag question

Question text

What is the output of the following code?

int main() {

   const x = 6.0;

   double y = 4.0;

   cout << (x / y);

   return 0;

}Select one:a. 1b. 1.5c. 2d. No output. Error in code. 

Correct

Feedback

The correct answer is: No output. Error in code.

Question 20

Correct2.50 points out of 2.50Flag question

Question text

Which statement defines a 16-bit unsigned integer variable?Select one:a. short short numSeconds;b. unsigned short numSeconds; 

Correct

c. unsigned int numSeconds;d. short numSeconds;

Feedback

The correct answer is: unsigned short numSeconds;

 

<h5 style="

"Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!":

Get started