Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 1 What is the difference between compile-time binding and run-time binding? 7 points QUESTION 2 float level; int *iptr = &level; Description of Correction:

QUESTION 1

What is the difference between compile-time binding and run-time binding?

7 points

QUESTION 2

float level;

int *iptr = &level;

Description of Correction:

Corrected Line of Code:

7 points

QUESTION 3

Look at the following code.

int x = 7;

int *iptr = &x;

What will be displayed if you send the expression *iptr to cout?

What happens if you send the expression iptr to cout?

7 points

QUESTION 4

Look at the following array definitions.

int numbers[ ] = {2, 4, 6, 8, 10};

What will the following statement display?

cout << *(numbers + 3) << endl;

7 points

QUESTION 5

What is the output for the following code.

int *length;

int *width;

length = new int;

*length = 5;

width = length;

length = new int;

*length = 2* (*width);

cout << *length << << *width << << (*length) * (*width) << endl;

7 points

QUESTION 6

What is the output for the following code.

int x = 50, y = 60, z = 70;

int *ptr;

cout << x << << y << << z << endl;

ptr = &x;

*ptr *=10;

ptr = &y;

*ptr *=5;

cout << x << << y << << z << endl;

7 points

QUESTION 7

Under what circumstances would you successfully return a pointer from a function?You should only return a pointer from a function if it is

a.

All of the above

b.

A pointer to an object that was passed into the function as an argument

c.

A pointer to a local objected declared in the function as an argument

d.

A pointer to a dynamically allocated object

7 points

QUESTION 8

Look at the following array definition.

int set[10];

Write a statement using pointer notation that stores the value 99 in set [7].

7 points

QUESTION 9

Rewrite the following loop so it uses pointer notation (with the indirection operator) instead of subscript notation.

for (int x = 0; x < 100; x++)

cout << arr[x] << endl;

7 points

QUESTION 10

int *pint;

pint = new int;

if (pint == NULL)

*pint = 100;

cout << Memory allocation error ;

Description of Correction:

Corrected Line of Code:

9 points

QUESTION 11

int *getNum ()

int wholeNum;

cout << Enter a number: ;

cin >> wholeNum;

return &wholeNum;

}

Description of Correction:

Corrected Line of Code:

9 points (Extra Credit)

QUESTION 12

What math operations are allowed on pointers?

a.

+

b.

-

c.

*

d.

/

e.

All of the above

7 points

QUESTION 13

int x, *ptr;

*ptr = &x;

Description of Correction:

Corrected Line of Code:

7 points

QUESTION 14

int ptr*;

Description of Correction:

Corrected Line of Code:

7 points

QUESTION 15

ptr is a pointer to an int, and holds the address 12000. On a system with 4-byte integers, what address will be in ptr after the following statement?

ptr +=10;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

3. How frequently do the assessments occur?

Answered: 1 week ago