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

1. The statement cin >> *num3; A) stores the keyboard input into the pointer cal

ID: 3548462 • Letter: 1

Question

1. The statement cin >> *num3;
A) stores the keyboard input into the pointer called num3
B) is illegal in C++.
C) stores the keyboard input into the variable pointed to by num3.
D) stores the keyboard input into the variable num3.

2. What will the value of result be after the following statement executes?

     result = 6 - 3 * 2 + 7 - 10 / 2 ;


a) 1.5
b) 2
c) 8
d) 6


3. What is the output of the following program?

#include <iostream>

using namespace std;

void showDub(int);

int main()

{

   int x = 2;

   showDub(x);

   cout << x << " ";

   return 0;

{

void showDub(int num)

{

   cout << (num * 2) << " ";

}
a) 2 4
b) 2 2
c) 4 2
d) 4 4


4.     What is assigned to the variable a given the statement below with the following assumptions: x = 6, y = 7, and z, a, and b are all int variables?

       a = x++ >= y;
a) 10
b) 1
c) The string "x >= y"
d) 0
e) 7

5. What is the output of the following statement?

     cout << tolower(toupper('Z')) << endl;


A) upper case Z
B) lower case z
C) a lower case z followed by an upper case Z
D) a compiler error

6. What is the value stored at x, given the statements:

           float x;

     x = 90.0 / static_cast<int>(4.5 + 6.4);


A) 0.9
B) 9
C) 0
D) .275229

7.  Look at the following code.

    int numbers[] = {0, 1, 2, 3, 4 };

    int *ptr = numbers;

    ptr++;

After this code executes, which of the following statements is true?






A) ptr will hold the address of numbers[1]
B) ptr will hold the address of the 2nd byte within the element numbers[0]
C) ptr will hold the address of numbers[0]
D) This code will not compile.

8. Which of the following might be a benefit of hiding a class's implementation from a programmer?
a) If the programmer knows how a function is implemented it might influence how the programmer uses that function
b) The programmer needs to know what the function does not how it works
c) The implementation ensures that the private data is protected and remains valid
d) All of the above are benefits
e) None of the above...that's crazy, of course the programmer needs to know how a class is implemented



9. Suppose you have written a C++ console program to prompt the user to enter a person's first and last name. You store the name in a variable called fullName. To be sure that you get the full name how should you code the input statement?
a) getline(cin, fullName);
b) cin >> fullName;
c) None of the above will work for inputting a name
d) cin >> fullName >> fullName;
e) getline(fullName);


10. In C-Sharp, to make a button object useable, you must code the button's

a) initialize event
b) start event
c) click event
d) access event

11. What will the following code output?

   int *numbers = new int[5];

   for (int i = 0; i <= 4; i++)

        *(numbers + i) = i;

   cout << numbers[2] << endl;


A) 2
B) 0
C) Five memory addresses
D) 1
E) 3

12. What will the following code output?

   int *numbers = new int[5];

   for (int i = 0; i <= 4; i++)

        *(numbers + i) = i;

   cout << numbers[2] << endl;
a) An address in memory
b) This code will not compile
c) 1
d) 2

13. Suppose you have written a C++ console program to prompt the user to enter a person's first and last name. You store the name in a variable called fullName. To be sure that you get the full name how should you code the input statement?
a) cin >> fullName;
b) getline(fullName);
c) getline(cin, fullName);
d) cin >> fullName >> fullName;
e) None of the above will work for inputting a name


Explanation / Answer

1. C) stores the keyboard input into the variable pointed to by num3.(tested)

2. BODMAS Rule-

3. showDub(int num) will ouput 4

main output =2

Hence output= 4 2 (option-c)


4. option-d.The output will be a logical value.It is a post increment means x value is changed only in next time


Since 6 <7 o/p=0


5. B) lower case z -Final operation matters.


6. B) 90/10=9: Here 10 comes from the int(6.4+4.5=10.9)=10


7. next array element---A) ptr will hold the address of numbers[1]


8. c) The implementation ensures that the private data is protected and remains valid


9. a).getline(cin, fullName);(waits for entire line-- untilll u press enter)


10. C which handles the button Click events


11. numbers variable is a address


hence a) 2- assigned address


12 (d).2


13 c.getline(cin, fullName);(waits for entire line-- untilll u press enter)