Machine-translated by Google. Questions are authored in English.
Top

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;
}

 

  • A.9
  • B.90.000000
  • C.90

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.