Exercise: Complicated Declarations

Questions for: Complicated Declarations

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("ExamAdept");
}
A:
Error: invalid parameter in function display()
B:
Error: invalid function call f=show;
C:
No error and prints "ExamAdept"
D:
No error and prints nothing.
Answer: C
No answer description is available. Let's discuss.
Point out the error in the following program.
#include<stdio.h>
#include<stdlib.h>

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: D
No answer description is available. Let's discuss.
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: C
No answer description is available. Let's discuss.
What will be the output of the program in Turbo C?
#include<stdio.h>

int main()
{
    char near *near *ptr1;
    char near *far *ptr2;
    char near *huge *ptr3;
    printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));
    return 0;
}
A:
4, 4, 8
B:
4, 4, 4
C:
2, 4, 8
D:
2, 4, 4
Answer: D
No answer description is available. Let's discuss.
What will be the output of the program?
#include<stdio.h>

int main()
{
    char huge *near *ptr1;
    char huge *far *ptr2;
    char huge *huge *ptr3;
    printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));
    return 0;
}
A:
4, 4, 8
B:
2, 4, 4
C:
4, 4, 2
D:
2, 4, 8
Answer: B
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz