Discussion
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;
}
Answer: B
Correct answer: 90.000000
f is an alias for float, so f *fptr is a float *. It is assigned the address of fval, and *fptr retrieves 90. Passed to printf, a float is promoted to double and %f prints it with six decimal places, giving 90.000000 rather than 90. The static qualifier affects storage duration only.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development