Menu Close

C exam on Pointers

Please enter your email:

1.

Output of following program?

#include<stdio.h>
int main()
{
  char *s[]={"live", "tution", "online", "class"};
  char **ptr[] = {s+1, s, s+3, s+2};
  char ***p;
  p = ptr;
  p+1;
  printf("%c ", *(*(*++p+1))+3);
  return 0;
}

 

 
 
 
 

2.

Comment on the following pointer declaration? [int *ptr, p;]

 
 
 
 

3.

Output of following program?

#include<stdio.h>
void main()
{
  char* s="Live Tution";
  int x=2 , y=3;
  y=x++ + ++x;
  printf("%s",(s+y));
}

 

 
 
 
 

4.

Which of the following is the correct way to declare a pointer to an array of 3 integer elements?

 
 
 
 

5.

Output of following program?

#include<stdio.h>
int main()
{
  int i = 100;
  int *ip1, *ip2;
  ip1 = &i;
  ip2 = ++ip1;
  --ip1;
  printf("%d ", ip2-ip1);
  return 0;
}

 

 
 
 
 

6.

What is a void pointer?

 
 
 
 

7.

Output of following program?

#include <stdio.h>
int main()
{
  int k = 5;
  int *p = &k;
  int **m = &p;
  printf("%d, %d, %d ", k, *++p, **m++);
  return 0;
}

 

 
 
 
 

8.

Output of following program?

#include <stdio.h>
int main()
{
  char* cp ;
  printf("%d ", sizeof(cp));
  printf("%d ", sizeof(double*));
  return 0;
}

 

 
 
 
 

9.

Output of following program?

#include <stdio.h>
int main()
{
  int *ptr, a=10;
  ptr = &a;
  *ptr += 1;
  printf("%d,%d", *ptr, a);
  return 0;
}

 

 
 
 
 

10.

Output of following program?

#include<stdio.h>
int main()
{
  int arr[5] = {10,20,30,40,50},i;
  int* ptr = arr;
  printf("%d ", *++ptr + 3);
  printf("%d ", *(ptr-- + 2) + 5);
  printf("%d ", *(ptr+3)-10);
  return 0;
}

 

 
 
 
 

Question 1 of 10