Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1. For the values given, what will c contain after executing the follow

ID: 3555439 • Letter: Q

Question

Question 1. For the values given, what will c contain after executing the following?

int a = 9, b = 4, c = -2;
c *= ++a % b;

       4
       -4
       -2
       2

Question 2. Which statement outputs a double value in a field of nine characters with three digits after the decimal point?

       cout << 9chars << 3digits << 1.2345678;
       cout << fixed << setprecision(9) << 1.2345;
       cout << setprecision(9) << setw(3) << 1.2345;
       cout << setprecision(3) << setw(9) << 1.2345678;

Question 3. For readability, all statements inside a loop body should be

       indented the same distance as the loop control statement.
       indented by one additional tab stop more than the loop control statement.
       surrounded by an open and closing parenthesis.
       written on the same line.

Question 4. What is the value of beta after the following code executes if the input is 1?

int beta;
cin >> beta;
switch(beta)
{
case 3:
beta += 3;
case 1:
beta++;
case 5:
beta += 5;
case 4:
beta += 4;
}

       14
       7
       2
       11

Question 5. How many times does the following loop body execute?

int count = 52;
for(int i = 0; i <= 26; i++)
{
      cout << count << endl;
      --count;
}

       26
       52
       27
       None of the above

Question 6. Trying to access an array element beyond the end of the array can lead to an attempt to access an address outside your program's memory space which is a

       runtime error.
       linker error.
       compiler error.
       All of the above

Question 7. An assertion statement

       is used to verify that some condition in your program is true.
       aborts your program if the asserted condition is false.
       outputs filename and line number information associated with a failed assertion.
       All of the above

Question 8. Testing repetition statements

       must validate that a loop repeats the correct number of times.
       controlled by complex conditionals can involve many test cases.
       must have a test case for each condition which terminates the loop.
       All of the above

Question 9. Which of the following statements about testing are true?

       Black box test cases can be written as soon as the problem statement and program requirements are specified.
       White box testing is typically done by the programmer as code is being developed.
       Both black box and white box testing are commonly done to fully test a program.
       All of the above

Question 10. When a variable is passed by reference as a function argument,

       its value is copied
       it can have its value both read and modified by the function
       it is protected from being modified by the function
       All of the above

Question 11. When should you use reference variables as function parameters?

       When the value of the actual parameter needs to be changed
       When you want to return one value from the function
       When you want the function to process a copy of the data
       None of the above

Question 12. An array is used in a program to

       gather together a set of related data items of various types.
       organize a collection of values of the same type.
       encapsulate a set of data behind methods which are provided to access the data.
       None of the above

Question 1. For the values given, what will c contain after executing the following?

int a = 9, b = 4, c = -2;
c *= ++a % b;

       4
       -4
       -2
       2

Explanation / Answer

1) -4

2) cout << setprecision(3) << setw(9) << 1.2345678;

3) indented by one additional tab stop more than the loop control statement.

4) 2

5) 27

6) runtime errror

7) All of the above

8)  must validate that a loop repeats the correct number of times.

9)All of the above

10) it can have its value both read and modified by the function

11) When the value of the actual parameter needs to be changed

12)  organize a collection of values of the same type.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote