=0;) { printf("%d ", *p--); i--; } } (a) 20 10 (b) 10 20 (c) 11 21 (d) 21 11 Q5. main() { static int a[]={2,4,6}; static int *p[]={a,a+1,a+2}; int *q[]={a+2,a+1,a} , *ptr, i; for(i=0;i<3;i++) a[i]=**p+**q; for(i=0;i<3;i++) printf("%d ",a[i]); } (a) 4 8 12 (b) 12 12 12 (c) 8 14 14 (d) 2 4 6 Q6. main() { static int a[]={2,4,6}; static int *p[]={a,a+1,a+2}; int *q[]={a+2,a+1,a}, *ptr, i; ; for(i=0;i<3;i++) a[i]=*p[i]+*q[i]; for(i=0;i<3;i++) printf("%d ",a[i]); } (a) 4 8 12 (b) 12 12 12 (c) 12 22 22 (d) 8 8 14 Q7. Suppose the array a starts with the base address 170 andarray p starts with the base address 180 main() { static int a[]={10,12,14,16,18}; static int *p[]={a,a+1,a+2,a+3,a+4} , **ptr, *s; ptr=p+0; s=a+0; printf("\n %u %u %d %d ",s,ptr,*s,**ptr); ptr++; s++; printf("\n %u %u %d %d ",s,ptr,*s,**ptr); *ptr++; *++s; printf("\n %u %u %d %d ",s,ptr,*s,**ptr); ++*ptr; ++*s; printf("\n %u %u %d %d ",s,ptr,*s,**ptr); *ptr++; *s++; printf("\n %u %u %d %d ",s,ptr,*s,**ptr); } Q8. main() { int a[5]={10,20,30,40,50},*p; int i; p=a; for(i=0;i<3;i++) printf(" %.4d ",++p[i]); } (a) 10 20 30 (b) 0010 0020 0030 (c) 0011 0021 0031 (d) all garbage Q9. main() { int a[][2][3]={ { {1,2,3}, { 4, 5, 6} }, { {7,8,9}, {10,11,12} } }; printf("%u ",***a+1+1+2); printf("%u ", ***(a+1)+1+2); printf("%u ",**(*(a+1)+1)+2); printf("%u ",*(*(*(a+1)+1)+2)); } (a) error (b) 1 12 12 12 (c) 1 10 11 12 (d) 5 10 12 12 Q10. main() { int a[]={10,20,30}; int *p[3]={a}, i; for(i=0;i<3;i++) printf("%u ",p[i]); } suppose the base address of array a is 170 (a) 170 172 174 (b) 170 0 0 (c) 170 and garbage addresses (d) no output Q11. main() { float x[3][3][3]={1.5,2.5}; printf("%.2f %.2f",x[0][0][0],x[2][2][2]); } (a) 1.50 garbage value (b) 1.50 2.50 (c) 0.00 0.00 (d) 1.50 0.00 ( e) none of these Q12. main() { int a[5]={10,20,30,40,50}, *p; p=a+4; p[-2]=50; printf("\n%u %d",p[-2],a[2]); } (a) 30 50 (b) error (c) 30 30 (d) 50 30 (e) none of these Q13. main() { int a[3]={10,20,30},*p; for(p=a;p<&a[3];p++) { *p=p-a; printf("%d ",*p); } } (a) 10 20 30 (b) garbage values (c) 1 2 3 (d) 0 1 2 (e) none of these Q14. main() { int a[3][3]; printf("%u ",&a+0); printf("%u ",&a+1); } if the base address is 65506 (a) 65506 65508 (b) 65506 65518 (c) 65506 65526 (d) 65606 65524 Q15. main() { int a[]={10,20,30} , (*p)[3]=a , i; for(i=0;i<3;i++) printf("%d ",(*p)[i]); } (a) 10 20 30 (b) 10 0 0 (c) 10 10 10 (d) 10 and all garbage values Q16. What will be the value of a[i] will be printed out in this program?. main() { int a[3] , i; for(i=0;i<3;i++) { a[i]=printf("abcde"+i); printf("%d",a[i]); } } (a) 97 98 99 (b) 1 2 3 (c) 5 4 3 (d) all garbage values Q17. main() { int a[]={10,20,30}, i,*p,j=0; for(i=0;i<3;i++) { p=&a[i]; ++*p++; ++a[j++]; printf("%d ",a[i]); } } (a) 10 20 30 (b) 11 21 31 (C) 12 22 32 (d) 13 23 33 Q18. main() { int a[]={10,11,12}, I; for(I=0;I<3;I++) ++*a; for(I=0;I<3;I++) printf(“%d”,a[I]); } (a) error (b) 10 11 12 (c) 11 12 13 (d) 12 13 15 (e) 13 11 12 Q19. main() { int a[][3]={1,2,3,4,5,6}; int (*p)[]={a}; printf(“%d %d”,(*p)[1],(*p)[2]); *p++; printf(“%d %d”,(*p)[1],(*p)[2]); } (a) 2 3 5 6 (b) 2 3 4 5 (c) 4 5 0 0 (d) compilation error Q20 main() { char a[ ]="Jyotir"; char b[ ]="Janmay"; char c[10]; c=a; a=b; b=c; printf("%s %s",a,b); } (a) Jyotir Janmay (b) Janmay Jyotir (c) Jyotir Jyotir (e) error Q21 main() { char *a="Jyotir"; char *b="Janmay"; char *c; c=a; a=b; b=c; printf("\n %s %s ",a,b); } (a) Jyotir Janmay (b) Janmay Jyotir (c) Jyotir Jyotir (d) Janmay Janmay Q22 main() { int *p=&"Janmayjay"; printf("%s",p); } (a) Compiolation Error (b) garbage (c) J (d) Janmayjay (e) none of these Q23 main() { char a[10][10]; char *b[10]; char (*c)[10]; printf("\n %d %d %d",sizeof(a),sizeof(b),sizeof(c)); } (a) 100 10 10 (b) 200 20 20 (c) 100 20 2 (d) none of these Q24. main() { char *a[2]={"Jyotir" , "Janmay"}; printf("\n%s",*a+1); printf("\n%s",*(a+1)); } (a) Jyotir Janmay (b) Janmay Janmay (c) yotir Janmay (d) none of thsee Q25. main() { static char *a[]={"Sanjay Sapra", "Janmayjay Sapra", "Jyotirmay Sapra"}; printf("%s",*(a+2)-16); } (a) Jyotirmay Sapra (b) Sanjay Sapra (c) Janmayjay Sapra (d) none of these Q26. main() { char a[]="AABBCC"; int i; for(i=0;i<3;i++) printf("%d",(int)a[i]); } (a) compilation error (b) 65 65 66 (c) 65 65 66 66 67 67 (d) 65 66 67 Q27. main() { char a[0]; printf("%d",sizeof(a)); } (a) compilation error (b) 1 (c) 2 (d) 0 Q28. main() { char s[ ]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); } Q29. What will be the output of this program if I store 3 strings at time of scanf( ). “Sanjay” “Jyotirmay” “Janmayjay” main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); } (a) S J J Sanjay Jyotirmay Janmayjay (b) S J J (c) S J J Sanjay anjay njay (d) S J J SJJanmayjay JJanmayjay Janmayjay Q30 main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); } Q31. main() { char *p = “Iyqm”; char c; c = ++*p++; printf(“%c”,c); printf(“%s”,p); } Q32. void main() { printf(“sizeof (void *) = %d \n“, sizeof( void *)); printf(“sizeof (int *) = %d \n”, sizeof(int *)); printf(“sizeof (double *) = %d \n”, sizeof(double *)); printf(“sizeof(struct unknown *) = %d \n”, sizeof(struct unknown*)); } Q33. main() { char a[ ]={10,20,30,40,50,60,70,80}; char *ptr; ptr=&(a+2)[5]; printf(“%d”,*ptr); } Q34. main() { char *str; str=(char*) malloc(12); strcpy(str,”Jyotirmay”); printf(“%s”,str); str=(char*) realloc(str,22); strcat(str,”Janmayjay”); printf(“%s”,str); } Q35. main( ) { static char *arr[ ]={ “sanjay”, “balou” , ”Janmay” , ”Jyotir” }; static char **ptr[ ]={ arr+3, arr+2, arr+1, arr}; char ***p=ptr; **p++; printf(“%s”,**p); printf(“%s”,*--*++p); printf(“%s”,*p[-2]+3); printf(“%s”,p[-1][-1]+1); } Q36. What will be output if you will compile and execute the following c code? void main() { int i=320; char *ptr=(char *)&i; printf("%d",*ptr); } (a) 320 (b) 1 (c) 64 (d) Compilation error Q37. What will be output if you will compile and execute the following c code? void main() { int array[]={10,20,30,40}; printf("%d",-2[array]); } (a) 60 (b) -30 (c) 60 (d) Garbage value (e) Compilation error Q38. int main() { char str[] = "Programming"; printf("%s ",&str[2]); printf("%s ",str); printf("%s ",&str); } Q39. What will be output if you will compile and execute the following c code? void main() { int i; float a=5.2; char *ptr; ptr=(char *)&a; for(i=0;i<=3;i++) printf("%d ",*ptr++); } (a)0 0 0 0 (b)Garbage Garbage Garbage Garbage (c)102 56 -80 32 (d**)102 102 -90 64 Q40. What will be output if you will compile and execute the following c code? void main() { printf("%s","c" "question" "bank"); } (a) c question bank (b) c (c) bank (**d) cquestionbank (e) Compiler error Q41. What will be the output of the following program main( ) { char a[ ]=”hello”, b[ ]=”hello”; if(a==b) printf(“String matched “); else printf(“String not matched”); } Q42. main( ) { printf(“%c”, “abcde”[2]); printf)”%c”,”abcde”+1)[2]); } Q43. main( ) { printf(“%s”, &“abcde”[2]); printf(”%s”,&”abcde”+1)[2]); } Q44. main() { static int a[3]={10,20,30},**c,****d; int *b[]={a,a+1,a+2,a+3,a+4}; c=b; d=&c; ++*++*c; printf("%d %d %d",a[0],a[1],a[2]); } Q45 main() { static int a[3]={10,20,30},***d; static int *b[]={a,a+1,a+2}; static int **c[]={b,b+1,b+2}; d=c; ++*++*++*d; printf("%d %d %d",a[0],a[1],a[2]); } Q46. main( ) { if(strcmp(&“abc”,&”abc”)) printf(“matched”); else printf(“not matched”); } (a) matched (b) not matched (c) no output (d) compilation error Q47. main( ) { if(strncmpi(“ramesh”,”RAMNARESH”,3)) printf(“matched”); else printf(“not matched”); } (a) matched (b) not matched (c) no output (d) compilation error Q48. What will the output? main( ) { int array[ ] = {1, 2, 3, 5, 8, 13, 21, 34, 55}; int sum = 0,i; for (i = 0; i < 4; i++) sum += array[array[i]]; printf(“%d”,sum); } Q49. What will the output? main() { char *p = NULL; char *q = 0; if (p) printf(" p "); else printf("nullp"); if (q) printf("q\n"); else printf(" nullq\n"); } Q50. int main() { int ary[4] = {1, 2, 3, 4}; int *p = ary + 3; printf("%d %d\n", p[-2], ary[*p]); } Q51. void main() { char a[10][5] = {"hi", "hello", "fellows"}; printf("%d", sizeof(a[1])); } Q52. What will be output of following program? int main(){ char *ptr1 = NULL; char *ptr2 = 0; strcpy(ptr1," c"); strcpy(ptr2,"questions"); printf("\n%s %s",ptr1,ptr2); return 0; } (a) c question (b) c (null) (c) (null) (null) (d) Compilation error (e) none of these Q53. What will be output of following program? int main(){ int a = 10; void *p = &a; int *ptr = p; printf("%u",*ptr); return 0; } (a) 10 (b) address (c) 2 (d) Compilation error Q54. What will be output of following program? int main( ) { int a,b,c,d; char *p = ( char *)0; int *q = ( int *q)0; float *r = ( float *)0; double *s = 0; a = (int)(p+1); b = (int)(q+1); c = (int)(r+1); d = (int)(s+1); printf("%d %d %d %d",a,b,c,d); return 0; } (a) 2 2 2 2 (b) 1 2 4 8 (c) 1 2 2 4 (d) compilation error Q55.What will be output of following program? int main() { int a = 5,b = 10,c; int *p = &a,*q = &b; c = p - q; printf("%d" , c); return 0; } (a) 1 (b) 5 (c) -5 (d) Error (e) None of these Q56. What will be output if you will compile and execute the following c code? int main() { int a[2][4]={3,6,9,12,15,18,21,24}; printf("%d %d %d",*(a[1]+2),*(*(a+1)+2),2[1[a]]); return 0; } (a) 15 18 21 (b) 21 21 21 (c) 24 24 24 (d) Error (e) None of these Q57. What will be output if you will compile and execute the following c code? int main() { char arr[]="C Question Bank"; char *p; p+=3; p=arr; p+=3; *p=100; printf("%s",arr); return 0; } (a) C question Bank (b) C quesdion Bank (c) C qdestion Bank (d) C q100estion Bank Q58. What will be output the following c code? int main() { int i; char *arr[4] = {"C","C++","Java","VBA"}; char *(*ptr)[4] = &arr; for(i=0;i<4;i++) printf("Address of String %d : %u\n",i+1,(*ptr)[i]); return 0; } Q59. What will be output the following c code? int main() { int i; char *arr[4] = {"C","C++","Java","VBA"}; char *(*ptr)[4] = &arr; for(i=0;i<4;i++) printf("String %d : %s\n",i+1,(*ptr)[i]); return 0; } Q60. What will be output the following c code? int main() { int i; char *arr[4] = {"C","C++","Java","VBA"}; char *(*ptr)[4] = &arr; printf("%s",++(*ptr)[2]); return 0; } "/>

Latest C Aptitude Question SOLUTION: ARRAY-SHEET Q1. main() { int n=10; int a[n]; printf("\n %d bytes",sizeof(a)); } (a) com