C. write

Question 22

Use a for statement to print the elements of array numbers using pointer/offset notation with pointer nPtr

b. cout << fixed << showpoint << setprecision(1);
for (int j = 0; j < SIZE; j++)

cout << *(nPtr + j) << ' ';

Question 24

How many times is Hello World printed by this program?

#include <iostream>

struct BS
{
BS()
{
std::cout << "Hello World" << std::endl;
}
unsigned int color;
};

struct mid1: virtual public BS { };
struct mid2: virtual public BS { };
struct mid3: public BS { };
struct mid4: public BS { };

struct DR: public mid1, public mid2,
public mid3, public mid4 { };

int main(int argc, char** argv)
{
DR d;
return 0;
}

3
Question 25

Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Print the address stored in fPtr.

d. cout << "The address stored in fPtr is " << fPtr << endl;

Question 28

What value gets printed by the program?
#include <iostream>

int main()
{
int x = 3;

switch(x)
{
case 0:
int x = 1;
std::cout << x << std::endl;
break;
case 3:
std::cout << x << std::endl;
break;
default:
x = 2;
std::cout << x << std::endl;
}

return 0;
}

c. nothing, it is ill-formed  


Question 29

Write one or more statements that perform the following task for and array called “fractions”. Print all the array elements using a for statement. Define the integer variable i as a control variable for the loop.

a. for (int i = 0; < arraySize; i++) cout << "fractions[" < arraySize << "] = " << fractions[arraySize ] << endl;

Question 30

By default, memory addresses are displayed as long integers

Ответ:

True False

Question 32

Declare variables sum and x to be of type int.

a. int sum, x;

Question 33

It is an error if an initializer list contains more initializers than there are elements in the array


Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: