Computer Science, asked by vstmoinao, 3 months ago

Give a C++ statement to Create a float pointer fptr​

Answers

Answered by sohelasu934
5

Answer:

Float pointer

All concepts are similar to the integer pointer. If you are directly reading this article, kindly go through the integer pointer topic before getting started with this. Data type is the only difference.

A float pointer only stores an address of a float variable.

Syntax

float *ptr;

Referencing and dereferencing of a float pointer

Example

#include<stdio.h>

int main()

{

float var = 3.1415,*ptr;

ptr = &var; //ptr references var

printf("Address of var = %x\n",&var);

printf("ptr is pointing to an address %x\n",ptr);

/* use '*' operator to access the value stored at ptr,

i.e. dereferencing ptr */

printf("Value stored at ptr = %f",*ptr);

return 0;

}

Run it

Output

For the sake of understanding better, let's assume the address of a variable var.

If we assume address of a variable var as 1024 then the output of the above program will be,

Explanation:

Hope it will help you. Have a great day.

Similar questions