1] What do the following declarations signify?
A. int *f();
B. int (*pf)();
C. char **argv;
D. void (*f[10])(int,int);
E. char far *scr;
F. char far *arr[10];
G. int (*a[5])(int far *p);
H. char far *scr1, *scr2;
I. int (*ftable[])(void) = {fadd,fsub,fmul,fdiv};
J. int (*ptr)[30];
K. int *ptr[30];
L. void *cmp();
M. void (*cmp)();
N. char (*(*f())[])();
O. char (*(*x[3])())[5];
P. void (*f)(int, void(*)());
Q. int **(*)(int **, int **(*)(int **, int **));
R. void(*)(void(*)(int *, void **), int(*)(void **, int *));
S. char far * far *ptr;
T. char far * near *ptr;
U. char far * huge *ptr;
2] What would be the output of the following program?
main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
3] What would be the output of the following program?
main()
{
char far * near *ptr1;
char far * far *ptr2;
char far * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
4] What would be the output of the following program?
main()
{
char huge * near *ptr1;
char huge * far *ptr2;
char huge * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
5] What would be the output of the following program?
main()
{
char huge * near * far *ptr1;
char near * far * huge *ptr2;
char far * huge * near *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
6] What would be the output of the following program?
main()
{
char huge * near * far *ptr1;
char near * far * huge *ptr2;
char far * huge * near *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(*ptr2),sizeof(**ptr3));
}
7] What would be the output of the following program?
main()
{
char huge * near * far *ptr1;
char near * far * huge *ptr2;
char far * huge * near *ptr3;
printf("%d %d %d",sizeof(*ptr1),sizeof(**ptr2),sizeof(ptr3));
}
8] What would be the output of the following program?
main()
{
char huge * near * far *ptr1;
char near * far * huge *ptr2;
char far * huge * near *ptr3;
printf("%d %d %d",sizeof(**ptr1),sizeof(ptr2),sizeof(*ptr3));
}
9] Are the following two declarations same? < Yes / No>
char far * far *scr;
char far far **scr;
10] How would you declare the following:
- An array of three pointers to chars.
- An array of three char pointers.
- A pointer to an array of three chars.
- A pointer to a function which receives an int pointer and returns a float pointer.
- A pointer to a function which receives nothing and returns nothing.
11] Can you write a program which would implement the follwoing declaration.
void (*f)(int, void (*)());
***********************************************************************
*********************** ANSWERS ***************************
***********************************************************************
1]
A] f is a funciton returning pointer to an int.
B] pf is a pointer to function which returns an int.
C] argv is a pointer to a char pointer.
D] f is an array of 10 function pointers, where each function receives two ints and returns nothing.
E] scr is a far pointer to a char. ( far pointer is a pointer which contains an address which lies outside the data segment).
F] arr is an array of 10 character pointers.
G] a is an array of 5 function pointers. Each of these functions receive a far pointer to an int and returns an int.
H] scr1 is a far pointer to a char, whereas scr2 is a near pointer to a char.
I] ftable is an array of 4 function pointers which point to the functions fadd(), fsub() etc. Each of these functions accept nothing and return an int.
J] ptr is a pointer to an array of 30 integers.
K] ptr is an array of 30 pointers ot integers.
L] cmp is a function returning pointer to void.
M] cmp is a pointer to function which returns a void.
N] f is a funciton returning pointer to array[] of pointer to function returning char.
O] x is an array of 3 pointers to functions returning pointer to an array of 5 chars.
P] f is a pointer to a funciton which returns nothing and receives as its parameter an integer and a pointer to a funciton which receives nothing and returns nothing.
Q] f is a pointer to a function which returns a pointer to an int pointer and receives two arguments: a pointer to an int pointer and a function pointer which points to a function which receives two pointers to int pointers an returns a pointer to an int pointer.
R] f is a pointer to a function which returns nothing and receives two arguments, both function pointers: the first function pointer points to a function which returns nothing but receives two arguments - an int pointer and a pointer to a void pointer; the second function pointer points to a function which returns an int pointer an receives a pointer to a void pointer and an int pointer.
S] ptr is a far pointer to a far pointer to a char, or in easier words, ptr contains a far address of a far pointer to a char.
T] ptr is a near pointer to a far pointer to a char, or in easier words, ptr contains a near address of a far pointer to a char.
U] ptr is a huge pointer to a far pointer to a char, or in easier words, ptr contains a huge address of a far pointer to a char.
2] 2 4 4
3] 2 4 4
4] 2 4 4
5] 4 4 2
6] 4 4 4
7] 2 2 2
8] 4 4 4
9] No.
10] char *ptr[3];
char *ptr[3];
char (*ptr)[3];
float *(*ptr)(int *);
void( *ptr)();
11] main()
{
void( *f)(int, void(*)());
void fun(int, void(*)());
void fun1();
void(*p)();
f = fun;
p = fun1;
(*f)(23,p);
}
void fun(int i, voud (*q)())
{
printf("Hello");
}
void fun1()
{
;
}
No comments:
Post a Comment