C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - Find Output of Program (Q.No. 5)
5.
What is the output of the program
#include<stdio.h>
int main()
{
    struct emp
    {
        char name[20];
        int age;
        float sal;
    };
    struct emp e = {"Tiger"};
    printf("%d, %f\n", e.age, e.sal);
    return 0;
}
0, 0.000000
Garbage values
Error
None of above
Answer: Option
Explanation:
When an automatic structure is partially initialized remaining elements are initialized to 0(zero).
Discussion:
30 comments Page 3 of 3.

Palanisuru said:   9 years ago
I am not understand this program, please explain in detail.
(1)

Silambarasan said:   6 years ago
The structure can be initialized inside the main function.

Krishna said:   1 decade ago
Why o/p is @ when use %c instead of %s in this program?

Prameela said:   1 decade ago
I got an error when I compile it can anyone explain?

Sivaramireddy said:   9 years ago
I can't understand the program. Please explain me.

Bhushan patil said:   10 years ago
Is structure is define in main function?

Kavita.C.Karjagar said:   1 decade ago
I can't understand plz explain in dept.

Sivaraman said:   1 decade ago
What is struct emp?

Ram krishna said:   1 decade ago
Thanks to sundar.

Keerthi said:   1 decade ago
Thankx sundar ji.


Post your comments here:

Your comments will be displayed after verification.