Point Out Errors

Question 1 :

Point out the error in the following program (in Turbo C under DOS).

#include < stdio . h >
union emp
{
    int empno;
    int age;
};

int main()
{
    union emp e = {10, 25};
    printf("%d %d", e.empno, e.age);
    return 0;
}


A). Error: Lvalue required
B). Error: Rvalue required
C). Error: cannot initialize more than one union member.
D). No error
Answer : Option C

Question 2 :

Point out the error in the following program.

#include < stdio . h >
#include

int main()
{
    static char *p = (char *)malloc(10);
    return 0;
}


A). Error: Lvalue required
B). Error: Rvalue required
C). Error: invalid *p declaration
D). No error
Answer : Option D

Question 3 :

Point out the error in the following program.

#include < stdio . h >
void display(int (*ff)());

int main()
{
    int show();
    int (*f)();
    f = show;
    display(f);
    return 0;
}
void display(int (*ff)())
{
    (*ff)();
}
int show()
{
    printf("IndiaPARINAM");
}


A). Error: invalid parameter in function display()
B). Error: invalid function call f=show;
C). No error and prints "IndiaPARINAM"
D). No error and prints nothing.
Answer : Option C