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;
}
Discussion:
6 comments Page 1 of 1.
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.
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.
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.
Krish said:
1 decade ago
Can any one explain why properly ?
Is it beacuse 90.000000 is the only float value in the options ?
Is it beacuse 90.000000 is the only float value in the options ?
Vinu said:
9 years ago
But the answer I get is 0 when executed in Turbo C. Why, can anyone explain me?
Sourav said:
8 years ago
@Vinu.
As this is float. So, 0's are padded
As this is float. So, 0's are padded
Sindhujaejju said:
8 years ago
Why static here? Why it's needed?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers