C Programming - Memory Allocation - Discussion

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

int main()
{
    union test
    {
        int i;
        float f;
        char c;
    };
    union test *t;
    t = (union test *)malloc(sizeof(union test));
    t->f = 10.10f;
    printf("%f", t->f);
    return 0;
}
10
Garbage value
10.100000
Error
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
22 comments Page 2 of 3.

Lakshmi prasanna said:   1 decade ago
I can't understand this, please explain from staring any one.

Shilpa said:   1 decade ago
Thank you. Apple.

I clarified my doubt, with your answer.

Vijay said:   1 decade ago
Is it possible to declare, define union in main() ?

Rajendra said:   9 years ago
Thanks for the detailed explanation.

Ltte said:   10 years ago
f tells its float not number*f.

MGR said:   7 years ago
Nice Explanation, Thanks all.

Sweety said:   1 decade ago
What does f in 10.10f imply?

Denish said:   8 years ago
Thanks for the explanation.

Anu said:   7 years ago
thanks all for explaining.

Baru said:   1 decade ago
Explanation please.


Post your comments here:

Your comments will be displayed after verification.