C-Pointers Question and Answer

C-Pointers Question and Answer
121. main ( )
{
char *a [ ]  = {"jaya", "mahe", "chandra", "buchi"};
printf ("%d", sizeof (a) / sozeof (char *));
}

  • 4
  • bytes for char
  • bytes for char*
  • error
Show Answer
122. main ( )
{
char *p = "abc";
char *q = "abc123";
while (*p++=*q++)
{
printf ("%c%c, *p, *q);
}
}
What will be the output of the above ?

  • aabbcc
  • aabbcc123
  • abcabc123
  • bbcc1a2b3c
Show Answer
123. What is the result of the expression for the following declaration ?
int A [ ] = {1, 2, 3, 4, 5 };
*A + 1 - *A +3
  • 2
  • -2
  • 4
  • none of the above
Show Answer
124. Which are valid ?
(i)Pointers can be added;
(ii)Pointers can be subtracted.
(iii)Integers can be added to pointers.

  • all correct
  • only options (i) and (ii)
  • only option (iii)
  • only options (ii) and (iii)
Show Answer
125. x = malloc (y). Which off the following statements is correct ?
  • x is the size of the memory allocated
  • y Points to the memory allocated
  • x points to the memory allocated
  • none of the above
Show Answer
126. p and q are pointers to the same type of data items. Which of these are valid ?
(i) *(p+q)
(ii) *(P-q)
(iii) *p-*q
  • all
  • options (i) and (ii)
  • option (iii) is valid sometimes
  • none of the above
Show Answer
127. int *i;
float *f;
char *c;
Which are the valid castings ?
(i) (int *) &c
(ii) (float *) &c
(iii) (char *) &i
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  • options (i), (ii) and (iii)
  • only options (i) and (iii)
  • only option (iii)
  • only options (i) and (ii)
Show Answer
128. int a = 'a', d = 'd';
char *b = "b", **c = "cr";
main ( )
{
mixup (a, b, &c);
}
mixup (int p1, char *p2, chr **p3)
{
int *temp;
...
}
What is the value of a and b in mixup at the beginning ?
  • a address of the variable b
  • 'a' 'b'
  • 'a' address of the value b in "b"
  • a b
Show Answer
129. main ( )
{
char s [ ] = "S.T.S.", *A;
print (s);
{
print (char *p)
{
while (*p ! = '\0')
{
if (*p ! = '' . ') printf ("%c", *p);
p++;
}
}
What is the output?
  • S.T.S.
  • STS
  • ST
  • S.T.
Show Answer
130. Find the output
void main()
{
int a[5]={2, 3, 4, 5}, *c=a;
(*c) --;
printf ("d", *c);
}
  • 4
  • 1
  • 2
  • Pointer can't be decremented
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test