C Programming - Typedef - Discussion

Discussion Forum : Typedef - Find Output of Program (Q.No. 4)
4.
What will be the output of the program?
#include<stdio.h>

int main()
{
    typedef float f;
    static f *fptr;
    float fval = 90;
    fptr = &fval;
    printf("%f\n", *fptr);
    return 0;
}
9
0
90.000000
90
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
6 comments Page 1 of 1.

Sindhujaejju said:   8 years ago
Why static here? Why it's needed?

Sourav said:   8 years ago
@Vinu.

As this is float. So, 0's are padded

Vinu said:   9 years ago
But the answer I get is 0 when executed in Turbo C. Why, can anyone explain me?

Krishna said:   1 decade ago
The pointer variable of f is *fptr.

fptr is having the address of the fval.

fval has the value of 90.

We initialise f as float.

*fptr provides the value of fval as 90.

fptr gives the address of 90.

Harsha kumar N (mysore) said:   1 decade ago
The pointer fptr contains the address where the value 90 is stored and in the printf statement we have printed it out using the format specifier for float %f hane 90 with six places after the decimal point gets get printed.

Krish said:   1 decade ago
Can any one explain why properly ?
Is it beacuse 90.000000 is the only float value in the options ?

Post your comments here:

Your comments will be displayed after verification.