Answer to Question #325187 in C for Anju

Question #325187

Consider the following declaration. For each of the following statements (a) to (f) write a


single statement to perform the indicated task.


float number1 = 7.3, number2;


(a) Declare the variable fPtr to be a pointer to an object of type float.


(b) Assign the address of variable number1 to pointer variable fPtr.


(c) Print the value of the object pointed to by fPtr together with a suitable message.


(d) Assign the value of the object pointed to by fPtr to the variable number2.


(e) Print the address of number1 together with a suitable message.


(f) Print the value stored in fPtr together with e suitable message


1
Expert's answer
2022-04-07T04:05:26-0400
#include <stdio.h>

int main() {
      float number1, number2;
      float *fPtr;
      number1 = 7.3;
      fPtr = &number1;
      printf("Value of the object pointed to by fPtr: %f\n", *fPtr);
      printf("Address of the object pointed to by fPtr: %p\n", fPtr);
    number2 = *fPtr;
    printf("number2 = %f\n", number2);
    printf("Address of number1 = %p\n", &number1);
    printf("Value stored in fPtr: %f\n", *fPtr);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS