C Programming - Structures, Unions, Enums

1.
Which of the following statements correct about the below program?
#include<stdio.h>

int main()
{
    struct emp
    {
        char name[25];
        int age;
        float sal;
    };
    struct emp e[2];
    int i=0;
    for(i=0; i<2; i++)
        scanf("%s %d %f", e[i].name, &e[i].age, &e[i].sal);

    for(i=0; i<2; i++)
        scanf("%s %d %f", e[i].name, e[i].age, e[i].sal);
    return 0;
}
Error: scanf() function cannot be used for structures elements.
The code runs successfully.
Error: Floating point formats not linked Abnormal program termination.
Error: structure variable must be initialized.
Answer: Option
Explanation:

Refer the explanation given for another problem:

http://www.indiabix.com/c-programming/floating-point-issues/discussion-136


2.
Which of the following statements correct about the below program?
#include<stdio.h>

int main()
{
    union a
    {
        int i;
        char ch[2];
    };
    union a u1 = {512};
    union a u2 = {0, 2};
    return 0;
}
1: u2 CANNOT be initialized as shown.
2: u1 can be initialized as shown.
3: To initialize char ch[] of u2 '.' operator should be used.
4: The code causes an error 'Declaration syntax error'
1, 2
2, 3
1, 2, 3
1, 3, 4
Answer: Option
Explanation:
No answer description is available. Let's discuss.

3.
Which of the following statements correctly assigns 12 to month using pointer variable pdt?
#include<stdio.h>

    struct date
    {
        int day;
        int month;
        int year;
    };
int main()
{
    struct date d;
    struct date *pdt;
    pdt = &d;
    return 0;
}
pdt.month = 12
&pdt.month = 12
d.month = 12
pdt->month = 12
Answer: Option
Explanation:
No answer description is available. Let's discuss.

4.
Which of the following statements correct about the below code?
maruti.engine.bolts=25;
Structure bolts is nested within structure engine.
Structure engine is nested within structure maruti.
Structure maruti is nested within structure engine.
Structure maruti is nested within structure bolts.
Answer: Option
Explanation:
No answer description is available. Let's discuss.