Blog Archive

Saturday, May 15, 2010

Pointers And Array Part1

Candidate Name:Anonymous
http://rahulbudholiya.blogspot.com
Balkans
Session 1:
time 1 Hour
Test 1: Pointers And Array Part1

Q1. What will be the result of following code.

Void main()
{
int a[5][2]={{0,5},{1,7},{2,6},{3,8},{4,9}};
int (*p)[3];
p=a;
clrscr();
printf("%d",*p[0]);
printf("%d",*p[1]);
printf("%d",*p[2]);
}

Q2. Tell the difference between following pointer declarations.
a) int const *p;
b) const int *p;

Q3. Rewrite following statement in postfix increment operator;
++*ptr //ptr can be any pointer

Q4. Write the equivalent pointer instruction to access following array element.
int a[10][10][10][10];
a[i][j][k][l]; // write the statement in the form of pointers

Q5. If size of array is 4 bytes then what will be the output of following code.
#include<stdio.h>
void main()
{
int array[] = {12,13,14,15,16};
printf(“%d%d%d”,sizeof(array),sizeof(*array),sizeof(array[0]));
return 0;
}

Q6. Will following code compile ? give reason.
void main()
{
char name[2] =”Garima.”;
printf(“%d”,name);
}



Q7. What will be the output of following code.
void main()
{
printf(“%c\n”,3[“Garima .”]);
}

Q8. What will be the output of following code. If answer in garbage then give reason.
Void main()
{
char *p;
p = “rahul”;
printf(“%s”,*&*&p);
}

Q9. Write the output of following program.
Void main ()
{
int a[10]= {11,32,4,65,12,90,26,83,100,401};
int *p;
int *q;
p = &a[1];
q= &a[3];
prinrf(“%d %d”,*q-*p,q-p);

}

Q10. Write the output of following program.
Void main ()
{
int a[10]= {11,32,4,65,12,90,26,83,100,401};
int *p;
int *q;
p = &a[1];
q= &a[3];
prinrf(“%d %d”,*q+*p,q+p);

}

Q11. Write the output of following program.
Void main ()
{
int a[10]= {11,32,4,65,12,90,26,83,100,401};
int *p;
int *q;
p = &a[1];
q= &a[3];
prinrf(“%d %d”,*q+2,q+2);

}

Q12. Write the output of following program.
Void main ()
{
int a[10]= {11,32,4,65,12,90,26,83,100,401};
int *p;
int *q;
p = &a[1];
q= &a[3];
prinrf(“%d %d”,*q*2,q*2);

}

Q13. Write a program to transform a given string’s every second element capital.
Example:-
If string is garima then output should be gArImA.

Q14. Write a function which accepts following array as parameter and print all the elements of the array.
int a[10][2][3]={//any initialization here};

Q15. What will be the value of a, after execution of following code.
int a=0;
int *pointer = &a;
pointer=10;

Q16. What printf will print on screen, in following code?
char *p = “RahulGarimDeepanshuAditi”;
printf(“%d”,sizeof(p));

Q17. What printf will print on screen, in following code?
int a[4] = {0,1,2};
printf(“%d%d%d%d”,a[0],a[1],a[2],a[3]);

No comments:

Post a Comment