C Programming - Structures, Unions, Enums - Discussion

Discussion Forum : Structures, Unions, Enums - Point Out Correct Statements (Q.No. 1)
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

Discussion:
11 comments Page 2 of 2.

Gopi said:   1 decade ago
Can any one explain this ?


Post your comments here:

Your comments will be displayed after verification.