logo

CuriousTab

CuriousTab

Discussion


Home C Programming Pointers Comments

  • Question
  • What will be the output of the program?
    #include<stdio.h>
    
    int main()
    {
        char *p;
        p="hello";
        printf("%s\n", *&*&p);
        return 0;
    }
    


  • Options
  • A. llo
  • B. hello
  • C. ello
  • D. h

  • Correct Answer
  • hello 


  • Pointers problems


    Search Results


    • 1. If the size of integer is 4bytes, What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          int arr[] = {12, 13, 14, 15, 16};
          printf("%d, %d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0]));
          return 0;
      }
      

    • Options
    • A. 10, 2, 4
    • B. 20, 4, 4
    • C. 16, 2, 2
    • D. 20, 2, 2
    • Discuss
    • 2. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          int arr[3] = {2, 3, 4};
          char *p;
          p = arr;
          p = (char*)((int*)(p));
          printf("%d, ", *p);
          p = (int*)(p+1);
          printf("%d", *p);
          return 0;
      }
      

    • Options
    • A. 2, 3
    • B. 2, 0
    • C. 2, Garbage value
    • D. 0, 0
    • Discuss
    • 3. What will be the output of the program?
      #include<stdio.h>
      
      void fun(void *p);
      int i;
      
      int main()
      {
          void *vptr;
          vptr = &i;
          fun(vptr);
          return 0;
      }
      void fun(void *p)
      {
          int **q;
          q = (int**)&p;
          printf("%d\n", **q);
      }
      

    • Options
    • A. Error: cannot convert from void** to int**
    • B. Garbage value
    • C. 0
    • D. No output
    • Discuss
    • 4. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          int x=30, *y, *z;
          y=&x; /* Assume address of x is 500 and integer is 4 byte size */
          z=y;
          *y++=*z++;
          x++;
          printf("x=%d, y=%d, z=%d\n", x, y, z);
          return 0;
      }
      

    • Options
    • A. x=31, y=502, z=502
    • B. x=31, y=500, z=500
    • C. x=31, y=498, z=498
    • D. x=31, y=504, z=504
    • Discuss
    • 5. What will be the output of the program If the integer is 4bytes long?
      #include<stdio.h>
      
      int main()
      {
          int ***r, **q, *p, i=8;
          p = &i;
          q = &p;
          r = &q;
          printf("%d, %d, %d\n", *p, **q, ***r);
          return 0;
      }
      

    • Options
    • A. 8, 8, 8
    • B. 4000, 4002, 4004
    • C. 4000, 4004, 4008
    • D. 4000, 4008, 4016
    • Discuss
    • 6. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          int i=3, *j, k;
          j = &i;
          printf("%d\n", i**j*i+*j);
          return 0;
      }
      

    • Options
    • A. 30
    • B. 27
    • C. 9
    • D. 3
    • Discuss
    • 7. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          printf("%c\n", 7["CuriousTab"]);
          return 0;
      }
      

    • Options
    • A. Error: in printf
    • B. Nothing will print
    • C. print "X" of CuriousTab
    • D. print "7"
    • Discuss
    • 8. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char str[] = "peace";
          char *s = str;
          printf("%s\n", s++ +3);
          return 0;
      }
      

    • Options
    • A. peace
    • B. eace
    • C. ace
    • D. ce
    • Discuss
    • 9. What will be the output of the program if the size of pointer is 4-bytes?
      #include<stdio.h>
      
      int main()
      {
          printf("%d, %d\n", sizeof(NULL), sizeof(""));
          return 0;
      }
      

    • Options
    • A. 2, 1
    • B. 2, 2
    • C. 4, 1
    • D. 4, 2
    • Discuss
    • 10. What will be the output of the program?
      #include<stdio.h>
      power(int**);
      int main()
      {
          int a=5, *aa; /* Address of 'a' is 1000 */
          aa = &a;
          a = power(&aa);
          printf("%d\n", a);
          return 0;
      }
      power(int **ptr)
      {
          int b;
          b = **ptr***ptr;
          return (b);
      }
      

    • Options
    • A. 5
    • B. 25
    • C. 125
    • D. Garbage value
    • Discuss


    Comments

    There are no comments.

Enter a new Comment