# Homework Solution: I need help with determining the output of these C++ statements….

I need help with determining the output of these C++ statements. Please explain your solution float a = 9.8, b = 7.2, *ptr1, *ptr2; short c = 13, *ptr3; ptr1 = &a; ptr2 = &b; ptr3 = &c; If the following statements, along with the five statements given above, are executed as part of complete programs, what will be printed? In any of the problems, if you think an error message will be produced, explain why. (a) int j; j = ptr3 - ptr1; cout << j; (b) short j; j = ptr2 - ptr1; cout << j; (c) ptr2 = 3*ptr1; cout << ptr2; (d) cout << ptr2 - 1; (e) cout << *(ptr2 - 1); (f) cout << (int)ptr3 - (int)ptr1;

a. error will be produced because ptr3 is of type short int and ptr1 is of type pointer f

I demand aid with determining the output of these C++ statements.

transport a = 9.8, b = 7.2, *ptr1, *ptr2;

abrupt c = 13, *ptr3;

ptr1 = &a;

ptr2 = &b;

ptr3 = &c;

If the followingcited statements, parallel with the five statements fond over, are executed as deal-out of total programs, what conquer be printed? In any of the problems, if you reflect an hallucination notice conquer be manufactured, teach why.

(a) int j;

j = ptr3 – ptr1;

cout << j;

(b) abrupt j;

j = ptr2 – ptr1;

cout << j;

(c) ptr2 = 3*ptr1;

cout << ptr2;

(d) cout << ptr2 – 1;

(e) cout << *(ptr2 – 1);

(f) cout << (int)ptr3 – (int)ptr1;

## Expert Solution

a. hallucination conquer be manufactured owing ptr3 is of likeness abrupt int and ptr1 is of likeness pointer transport so division cannot be executed among them.

b. output is 1 it displays the unlikeness among the adreesses the orderly transports are assigned single following another.

c. hallucination as 3 is of likeness int and ptr1 is a transport pointer swarming cannot be executed.

d. output is vague it varies according to discourse which is alloted to variable

e. the output is 9.8 as the discourse of ptr1 is ptr2-1 and * referes to the treasure at that discourse

f. hallucination as pointers of abrupt int and transport cannot be converted to int