Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Tcarteronw
T
Tcarteronw
Community Contributor
Quizzes Created: 38 | Total Attempts: 32,005
| Attempts: 1,182 | Questions: 17
Please wait...
Question 1 / 17
0 %
0/100
Score 0/100
1. If x has the value of 3, y has the value of -2, and w is 10, is the following condition true or false? if( x < 2 && w < y)

Explanation

The condition in the if statement is false because both parts of the logical operator && (AND) need to be true for the overall condition to be true. In this case, x is not less than 2, so the first part of the condition is false. Therefore, the overall condition is false.

Submit
Please wait...
About This Quiz
C++ Quiz 2 - Quiz

C++ Quiz 2 tests understanding of basic C++ programming concepts including identifiers, arithmetic operations, input\/output operations, and data representation. It is designed to evaluate practical skills in C++ coding and problem-solving.

Tell us your name to personalize your report, certificate & get on the leaderboard!
2. What is the correct way to write the condition y < x < z?

Explanation

The correct way to write the condition y

Submit
3. Which of the following is not a valid identifier?

Explanation

The identifier "return" is not valid because it is a reserved keyword in many programming languages, including Java. Reserved keywords have special meanings in the language and cannot be used as identifiers for variables, functions, or classes.

Submit
4. What is the value of x after the following statements? int x; x = 15 %4;

Explanation

The value of x after the given statements is 3. The expression "15 % 4" calculates the remainder when 15 is divided by 4, which is 3. Therefore, the value of x is assigned as 3.

Submit
5. What is the value of x after the following statements? int x; x = 0; x = x + 30;

Explanation

The value of x is initially set to 0. Then, x is incremented by 30 using the statement "x = x + 30". Therefore, the final value of x is 30.

Submit
6. Given the following code fragment, what is the output? int x=5; if( x > 5)     cout << "x is bigger than 5. ";     cout <<"That is all. "; cout << "Goodbye\n";

Explanation

The output of the code will be "That is all. Goodbye". This is because the condition in the if statement is false (x is not greater than 5), so the code inside the if statement will not be executed. The code after the if statement will be executed, which includes printing "That is all. " and "Goodbye".

Submit
7. What is the value of x after the following statements? double x; x = 0; x += 3.0 * 4.0; x -= 2.0;

Explanation

The variable x is declared as a double and initialized with the value 0. Then, the value of x is updated by adding the result of multiplying 3.0 and 4.0, which is 12.0. Finally, the value of x is updated again by subtracting 2.0. Therefore, the final value of x is 10.0.

Submit
8. Another way to write the value 3452211903 is

Explanation

The given answer, 3.452211903e09, represents the scientific notation of the value 3452211903. In scientific notation, a number is expressed as a decimal number between 1 and 10, multiplied by a power of 10. In this case, the decimal number is 3.452211903 and it is multiplied by 10 raised to the power of 9. This notation is commonly used to represent very large or very small numbers in a concise and standardized format.

Submit
9. Which of the following lines correctly reads a value from the keyboard and stores it in the variable named myFloat?

Explanation

The correct answer is "cin >> myFloat;". This line of code uses the ">>" operator to read a value from the keyboard and store it in the variable named myFloat. The "cin" object is used to read input from the keyboard, and the ">>" operator is used to extract the input and store it in the variable.

Submit
10. Executing one or more statements one or more times is known as:

Explanation

Iteration refers to the process of executing one or more statements repeatedly. It involves the use of loops to repeatedly perform a set of instructions until a certain condition is met. This allows for efficient and controlled repetition of code, making it easier to handle tasks that require repeated execution. Therefore, iteration is the correct term for executing statements multiple times.

Submit
11. Match the following items.
Submit
12. Match the following items with the correct choice.
Submit
13. What is the output of the following code? float value; value = 33.5; cout << "value" << endl;

Explanation

The code initializes a variable "value" of type float and assigns it the value 33.5. The next line prints the string "value" followed by a newline character. Therefore, the output of the code is the string "value".

Submit
14. What is the value of x after the following statement? float x; x = 3.0 / 4.0 + 3  + 2 / 5

Explanation

The value of x is 3.75. In the given statement, the expression is evaluated from left to right. The first operation is 3.0 divided by 4.0, which equals 0.75. Then, 0.75 is added to 3, resulting in 3.75. Finally, 2 divided by 5 is 0.4, but since it is an integer division, the result is 0. Therefore, the final value of x is 3.75.

Submit
15. What is the value of x after the following statements? float x; x = 15/4;

Explanation

The value of x after the given statements is 3.0. In the statement x = 15/4, the division operation is performed between two integers, which results in an integer division. In integer division, the decimal part is truncated, and only the whole number part is considered. Therefore, 15 divided by 4 equals 3 with a remainder of 3. The remainder is discarded, and the value assigned to x is the whole number part, which is 3.0 in this case.

Submit
16. Match the following items with the correct choice.
Submit
17. Given the following code fragment, what is the final value of y? int x, y; x = -1; y = 0; while(x <= 3) {     y += 2;     x += 1; }

Explanation

The code fragment initializes x to -1 and y to 0. Then, it enters a while loop that continues as long as x is less than or equal to 3. Inside the loop, y is incremented by 2 and x is incremented by 1. This process continues until x becomes 4, at which point the loop exits. Therefore, the final value of y is 10.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • May 21, 2013
    Quiz Created by
    Tcarteronw
Cancel
  • All
    All (17)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
If x has the value of 3, y has the value of -2, and w is 10, is the...
What is the correct way to write the condition y < x < z?
Which of the following is not a valid identifier?
What is the value of x after the following statements?...
What is the value of x after the following statements?...
Given the following code fragment, what is the output?...
What is the value of x after the following statements?...
Another way to write the value 3452211903 is
Which of the following lines correctly reads a value from the keyboard...
Executing one or more statements one or more times is known as:
Match the following items.
Match the following items with the correct choice.
What is the output of the following code?...
What is the value of x after the following statement?...
What is the value of x after the following statements?...
Match the following items with the correct choice.
Given the following code fragment, what is the final value of y?...
Alert!

Advertisement