|
Pointers
- Part II
|
|
[Q001] What
will be the output of the following program
:
int
main() { int
val=1234; int*
ptr=&val; printf("%d
%d",++val,*ptr); return(0); }
|
|
(a)1234 1234 (b)1235
1235 (c)1234 1235 (d)1235
1234
|
|
|
|
[Q002] What will be the output of the
following program :
int
main() { int
val=1234; int*
ptr=&val; printf("%d
%d",val,*ptr++); return(0); }
|
|
(a)1234 1234 (b)1235
1235 (c)1234 1235 (d)1235
1234
|
|
|
[Q003] What will be the output of the
following program :
int
main() { int
val=1234; int
*ptr=&val; printf("%d
%d",val,++*ptr); return(0); }
|
|
(a)1234
1234 (b)1235 1235 (c)1234
1235 (d)1235 1234
|
|
|
[Q004] What will be the output of the
following program :
int
main() { int val=1234; int
*ptr=&val; printf("%d %d",val,(*ptr)++); return(0); }
|
|
(a)1234 1234 (b)1235
1235 (c)1234 1235 (d)1235
1234
|
|
|
[Q005] What will be the output of the
following program :
int
main() { int val=1234; int
*ptr=&val; printf("%d %d",++val,(*(int *)ptr)--); return(0); }
|
|
(a)1234
1233 (b)1235 1234 (c)1234
1234 (d)None of these
|
|
|
[Q006] What will be the output of the
following program :
int
main() { int
a=555,*ptr=&a,b=*ptr; printf("%d %d
%d",++a,--b,*ptr++); return(0); }
|
|
(a)Compile-Time
Error (b)555 554 555 (c)556 554
555 (d)557 554 555
|
|
|
|
[Q007] What will be the output of the
following program :
int
main() { int a=555,b=*ptr,*ptr=&a;
printf("%d %d %d",++a,--b,*ptr++); return(0); }
|
|
(a)Compile-Time
Error (b)555 554 555 (c)556 554
555 (d)557 554 555
|
|
|
|
[Q008] What will be the output of the
following program :
int
main() { int
a=555,*ptr=&a,b=*ptr; printf("%d %d
%d",a,--*&b,*ptr++); return(0); }
|
|
(a)Compile-Time
Error (b)555 554 555 (c)556 554
555 (d)557 554 555
|
|
|
[Q009] What will be the output of the
following program :
int
main() { int a=555,*ptr=&a,b=*ptr=777; printf("%d
%d",--*&b,*(int
*)&b); return(0); }
|
|
(a)Compile-Time
Error (b)776 777 (c)554
555 (d)None of these
|
|
|
|
[Q010] What will be the output of the
following program :
int
main() { int
a=5u,*b,**c,***d,****e;
b=&a; c=&b;
d=&c; e=&d;
printf("%u %u %u
%u",*b-5,**c-11,***d-6,65535+****e); return(0); }
|
|
(a)Compile-Time Error (b)0
65530 65535 4 (c)0 65530 65535
65539 (d)0 -6 -1 -2
|
|
|
[Q011] What will be the
output of the following program :
int
main() { float
val=5.75; int
*ptr=&val; printf("%.2f
%.2f",*(float
*)ptr,val); return(0); }
|
|
(a)Compile-Time
Error (b)5.75 5.75 (c)5.00
5.75 (d)None of these
|
|
|
|
[Q012] What will be the output of the
following program :
int
main() { int
val=50; const int
*ptr1=&val; int const
*ptr2=ptr1; printf("%d %d
%d",++val,*ptr1,*ptr2); *(int
*)ptr1=98; printf("\n%d %d
%d",++val,*ptr1,*ptr2); return(0); }
|
|
(a)Compile-Time Error (b)51 50
50 99 98
98 (c)Run-Time Error (d)None of
these
|
|
|
|
[Q013] What will be the output of the
following program :
int
main() { int
val=77; const int
*ptr1=&val; int const
*ptr2=ptr1; printf("%d %d
%d",--val,(*ptr1)++,*ptr2); return(0); }
|
|
(a)Compile-Time Error (b)77 78
77 (c)76 77 77 (d)77 77
77
|
|
|
[Q014] What will be the output of the
following program :
int
main() { int
a=50,b=60; int* const
ptr1=&a; printf("%d
%d",--a,(*ptr1)++);
ptr1=&b; printf("\n%d
%d",++b,(*ptr1)++); return(0); }
|
|
(a)Compile-Time
Error (b)49 50 61
60 (c)50 50 62
60 (d)None of these
|
|
|
|
[Q015] What will be the output of the
following program :
int
main() { int
a=50; const int* const
ptr=&a; printf("%d
%d",*ptr++,(*ptr)++); return(0); }
|
|
(a)Compile-Time
Error (b)51 51 (c)51
50 (d)None of these
|
|
|
|
[Q016] What will be the output of the
following program :
int
main() { int val=77; const int const
*ptr=&val; printf("%d",*ptr); return(0); }
|
|
(a)Compile-Time
Error (b)Run-Time
Error (c)77 (d)None of
these
|
|
|
[Q017] What will be the output of the
following program :
int
main() { int
a[]={1,2,3,4,5,6}; int
*ptr=a+2; printf("%d
%d",--*ptr+1,1+*--ptr); return(0); }
|
|
(a)Compile-Time
Error (b)1 2 (c)2 3 (d)1
3
|
|
|
[Q018] What will be the output of the
following program :
int
main() { int
a[]={1,2,3,4,5,6}; int
*ptr=a+2; printf("%d
%d",*++a,--*ptr); return(0); }
|
|
(a)Compile-Time
Error (b)2 2 (c)3 2 (d)4
2
|
|
|
[Q019] What will be the output of the
following program :
int
main() { int
matrix[2][3]={{1,2,3},{4,5,6}};
printf("%d %d
%d\n",*(*(matrix)),*(*(matrix+1)+2),*(*matrix+1));
printf("%d %d
%d",*(matrix[0]+2),*(matrix[1]+1),*(*(matrix+1))); return(0); }
|
|
(a)Compile-Time
Error (b)1 5 2 6 3
4 (c)1 6 2 3 5
4 (d)1 6 2 3 4
5
|
|
|
[Q020] What will be the output of the
following program :
int
main() { int
(*a)[5]; printf("%d
%d",sizeof(*a),sizeof(a)); return(0); }
|
|
(a)Compile-Time
Error (b)2 5 (c)5 2 (d)None
of these
|
|
Solutions for the above
queries.
|
|
Back
|
|
Next
|
|