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

NOTE PLEASE DO THIS IN CTT PROGRAMMING Thank you Question 1 Consider these follo

ID: 3762899 • Letter: N

Question

NOTE PLEASE DO THIS IN CTT PROGRAMMING Thank you

Question 1


Consider these following two lines:

double n = 777;

cout << " n is: " << n << endl;

Write in one line the expressions to print the address of n.

QUESTION 2

Consider the following two lines:

double n = 777;

double &d = n;

Which of the following statements are true? select all that are true. Use your IDE to check your answer.

A.

d is the address of n

B.

d = 777

C.

d is a reference for n

D.

n is the address of d

QUESTION 3

Consider the following two lines:

int n = 777;

int &d = n;

d %= 7;

What is the value in n? Use your IDE to check your answer.

QUESTION 4

Let cosider the following two lines:

int num =2015;

int & ref = num;

The address of num is different from the address of ref.

True

False

QUESTION 5

Let consider the following two lines:

int num = 12;

int* p = num;

Select all true statements

A.

p is a pointer

B.

num holds the address of p

C.

num = 12

D.

p holds the address of num

QUESTION 6

Let consider the following:

int num = 128;

int* p = #

int& ref = *p;

What is the value in ref?

QUESTION 7

Let consider the following:

int num = 128;

int* p = num;

int& ref = *p;

Select all true statements:

A.

ref is a reference for p

B.

p points to num

C.

num is a reference for p

D.

ref is a reference for num

QUESTION 8

Let consider the following sequence of instructions:

const int size =5;

short a[size] = {11, 22, 33, 44, 55};

Select the true statement(s)

A.

a points to the address of 55

B.

a points to the address of 11

C.

a is not a pointer

D.

a = 11d

QUESTION 9

Let consider the following sequences:

const int size =5;

int a[size] = {11,22, 33, 44, 55};

int* f = a + size - 1;   

A.

f is the address of size (size = 5)

B.

f = 22

C.

f represents the adresss of 55

D.

f represents the address of 11

QUESTION 10

Let consider the following sequences:

short a[] = {11, 22, 33, 44, 55};

for (short* p = a; p < a + 5; p++)

{cout << "p = " << p << ", *p = " << *p << endl;}

What does this code display?

A.

only address related to the array a[]

B.

only values in the array a[]

C.

Nothing

D.

Both the addresses of values in the array a[] and the values

QUESTION 11

Let consider the following declaration and initialization:

int arr[5] = {5, 30, 14 22, 33};

Write one line expression to display the address of 22 using "arr"

QUESTION 12

Consider the following void function:

void print(double* a, int n)

{

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

cout << a[i] << " "; cout << endl;

}

What does it do?

Explanation / Answer

//cout << "Address of n is : " << &n << endl;

//d is a reference for n

//value in n is 0

//False

//p is a pointer,num = 12

//value in address pointed by p

//above statement will generate error. --int *p = num

//a points to the address of 11

//f represents the adresss of 55

//Both the addresses of values in the array a[] and the values

//cout << *(arr+3)

//prints all the value present in the array