C Programming - Complicated Declarations
|
|
|
|
Exercise"When ambition ends, happiness begins."
- (Proverb)
|
| 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 D
Explanation:
No answer description available for this question. Let us discuss.
|
| 2. |
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: Option C
Explanation:
No answer description available for this question. Let us discuss.
|
| 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("IndiaBIX");
}
|
| A. |
Error: invalid parameter in function display() | | B. |
Error: invalid function call f=show; | | C. |
No error and prints "IndiaBIX" | | D. |
No error and prints nothing. |
Answer: Option E
Explanation:
No answer description available for this question. Let us discuss.
|
|
|