• ( 1 ) Comment on the following pointer declaration?
      int *ptr, p;

    • 1) ptr is a pointer to integer, p is not.
    • 2) ptr and p, both are pointers to integer.
    • 3) ptr is pointer to integer, p may or may not be.
    • 4) ptr and p both are not pointers to integer.
    • Discussion in forum
      Answer : 1) ptr is a pointer to integer, p is not.
      Solution :








      discussion


      Answer : 1) ptr is a pointer to integer, p is not.

    • ( 2 ) Address stored in the pointer variable is of type __________.

    • 1) Floating
    • 2) Integer
    • 3) Character
    • 4) Array
    • Discussion in forum
      Answer : 2) Integer
      Solution : Pointer Variable of any type contains integer address because address of variable is always integer.








      discussion


      Answer : 2) Integer

    • ( 4 ) calloc(m, n); is equivalent to

    • 1) malloc (m*n, 0); **
    • 2) memset(0, m*n);
    • 3) ptr = malloc (m*n); memset (p, 0, m*n);
    • 4) ptr = malloc(m*n); strcpy(p, u);
    • Discussion in forum
      Answer : 3) ptr = malloc (m*n); memset (p, 0, m*n);
      Solution :








      discussion


      Answer : 3) ptr = malloc (m*n); memset (p, 0, m*n);

    • ( 5 ) In C a pointer variable to an integer can be created by the decalaration

    • 1) int p*; **
    • 2) int *p;
    • 3) int +p;
    • 4) int $p;
    • Discussion in forum
      Answer : 2) int *p;
      Solution :








      discussion


      Answer : 2) int *p;

    • ( 6 ) Which of the following is the proper keyword to allocate memory in C?

    • 1) new
    • 2) malloc
    • 3) create
    • 4) value
    • Discussion in forum
      Answer : 2) malloc
      Solution :








      discussion


      Answer : 2) malloc

    • ( 7 ) int main()
      {
      int x = 10,y;
      int*w=&x;
      y=*w;
      *w=20;
      printf("%d %d %d,x,y,*w");
      getch();
      }

    • 1) 20 10 20
    • 2) 10 10 20
    • 3) 20 20 20
    • 4) 10 20 20
    • Discussion in forum
      Answer : 1) 20 10 20
      Solution :








      discussion


      Answer : 1) 20 10 20

    • ( 8 ) Find the output of the following program.
      void main()
      {
      int array[10];
      int *i = &array[2], *j = &array[5];
      int diff = j-i;
      printf("%d", diff);
      }

    • 1) 3
    • 2) 6
    • 3) Garbage value
    • 4) Error
    • Discussion in forum
      Answer : 1) 3
      Solution :








      discussion


      Answer : 1) 3

    • ( 9 ) What will be output of following program?
      #include
      int main()
      {
      char far *p =(char far *)0x55550005;
      char far *q =(char far *)0x53332225;
      *p = 80;
      (*p)++;
      printf("%d",*q);
      return 0;
      }

    • 1) 80
    • 2) 81
    • 3) 82
    • 4) Compilation error
    • Discussion in forum
      Answer : 2) 81
      Solution :








      discussion


      Answer : 2) 81

    • ( 10 ) What will be output of following program?
      #include
      #include
      int main()
      {
      char *ptr1 = NULL;
      char *ptr2 = 0;
      strcpy(ptr1," c");
      strcpy(ptr2,"questions");
      printf("\n%s %s",ptr1,ptr2);
      return 0;
      }

    • 1) c questions
    • 2) c (null)
    • 3) (null) (null)
    • 4) Compilation error
    • Discussion in forum
      Answer : 3) (null) (null)
      Solution :








      discussion


      Answer : 3) (null) (null)





Top