logo

CuriousTab

CuriousTab

Discussion


Home C Programming Pointers Comments

  • Question
  • 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

  • Correct Answer
  • 4, 1 

    Explanation
    In TurboC, the output will be 2, 1 because the size of the pointer is 2 bytes in 16-bit platform.

    But in Linux, the output will be 4, 1 because the size of the pointer is 4 bytes.

    This difference is due to the platform dependency of C compiler.

    Pointers problems


    Search Results


    • 1. 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
    • 2. 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
    • 3. 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
    • 4. 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
    • Discuss
    • 5. 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
    • 6. 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
    • 7. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          int i, a[] = {2, 4, 6, 8, 10};
          change(a, 5);
          for(i=0; i<=4; i++)
              printf("%d, ", a[i]);
          return 0;
      }
      void change(int *b, int n)
      {
          int i;
          for(i=0; i<n; i++)
              *(b+1) = *(b+i)+5;
      }
      

    • Options
    • A. 7, 9, 11, 13, 15
    • B. 2, 15, 6, 8, 10
    • C. 2 4 6 8 10
    • D. 3, 1, -1, -3, -5
    • Discuss
    • 8. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7, 8};
          int *p, *q;
          p = &arr[1][1][1];
          q = (int*) arr;
          printf("%d, %d\n", *p, *q);
          return 0;
      }
      

    • Options
    • A. 8, 10
    • B. 10, 2
    • C. 8, 1
    • D. Garbage values
    • Discuss
    • 9. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char str[20] = "Hello";
          char *const p=str;
          *p='M';
          printf("%s\n", str);
          return 0;
      }
      

    • Options
    • A. Mello
    • B. Hello
    • C. HMello
    • D. MHello
    • Discuss
    • 10. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          static char *s[] = {"black", "white", "pink", "violet"};
          char **ptr[] = {s+3, s+2, s+1, s}, ***p;
          p = ptr;
          ++p;
          printf("%s", **p+1);
          return 0;
      }
      

    • Options
    • A. ink
    • B. ack
    • C. ite
    • D. let
    • Discuss


    Comments

    There are no comments.

Enter a new Comment