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
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
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
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
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”);
}
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("qn");
else
printf(" nullqn");
}
Q50. int main()
{
int ary[4] = {1, 2, 3, 4};
int *p = ary + 3;
printf("%d %dn", p[-2], ary[*p]);
}
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 : %un",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 : %sn",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;
}
Language is remarkable, except under the extreme constraints of mathematics and logic, it never can talk only about what it's supposed to talk about but is always spreading around.
Raju Sharma
The essence of mathematics is not to make simple things complicated, but to make complicated things simple.