Problem

Each of the following declarations and program segments has errors. Locate as many as y...

Each of the following declarations and program segments has errors. Locate as many

as you can.

A) int ptr*;

B) int x, *ptr;

&x = ptr;

C) int x, *ptr;

*ptr = &x;

D) int x, *ptr;

ptr = &x;

ptr = 100; // Store 100 in x

cout << x << endl;

E) int numbers[] = {10, 20, 30, 40, 50};

cout << "The third element in the array is ";

cout << *numbers + 3 << endl;

F) int values[20], *iptr;

iptr = values;

iptr *= 2;

G) double level;

int dPtr = &level;

H) int *iptr = &ivalue;

int ivalue;

I) void doubleVal(int val)

{

*val *= 2;

}

J) int *pint;

new pint;

K) int *pint;

pint = new int;

pint = 100;

L) int *pint;

pint = new int[100]; // Allocate memory

.

.

Process the array

.

.

delete pint;// Free memory

M) int *getNum()

{

int wholeNum;

cout << "Enter a number: ";

cin >> wholeNum;

return &wholeNum;

}

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT