logo

CuriousTab

CuriousTab

Discussion


Home C Programming Pointers Comments

  • Question
  • What will be the output of the program assuming that the array begins at location 1002?
    #include<stdio.h>
    
    int main()
    {
        int a[2][3][4] = { {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2}, 
                           {2, 1, 4, 7, 6, 7, 8, 9, 0, 0, 0, 0} };
        printf("%u, %u, %u, %d\n", a, *a, **a, ***a);
        return 0;
    }
    


  • Options
  • A. 1002, 2004, 4008, 2
  • B. 2004, 4008, 8016, 1
  • C. 1002, 1002, 1002, 1
  • D. Error

  • Correct Answer
  • 1002, 1002, 1002, 1 


  • Pointers problems


    Search Results


    • 1. What will be the output of the program assuming that the array begins at the location 1002 and size of an integer is 4 bytes?
      #include<stdio.h>
      
      int main()
      {
          int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
          printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1));
          return 0;
      }
      

    • Options
    • A. 448, 4, 4
    • B. 520, 2, 2
    • C. 1006, 2, 2
    • D. Error
    • Discuss
    • 2. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char str1[] = "India";
          char str2[] = "CURIOUSTAB";
          char *s1 = str1, *s2=str2;
          while(*s1++ = *s2++)
              printf("%s", str1);
      
          printf("\n");
          return 0;
      }
      

    • Options
    • A. CuriousTab
    • B. BndiaBIdiaCURIOUSTABia
    • C. India
    • D. (null)
    • Discuss
    • 3. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char *str;
          str = "%s";
          printf(str, "K\n");
          return 0;
      }
      

    • Options
    • A. Error
    • B. No output
    • C. K
    • D. %s
    • Discuss
    • 4. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char *str;
          str = "%d\n";
          str++;
          str++;
          printf(str-2, 300);
          return 0;
      }
      

    • Options
    • A. No output
    • B. 30
    • C. 3
    • D. 300
    • Discuss
    • 5. Is it true that too many recursive calls may result into stack overflow?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 6. What will be the output of the program?
      #include<stdio.h>
      #include<string.h>
      
      int main()
      {
          int i, n;
          char *x="Alice";
          n = strlen(x);
          *x = x[n];
          for(i=0; i<=n; i++)
          {
              printf("%s ", x);
              x++;
          }
          printf("\n", x);
          return 0;
      }
      

    • Options
    • A. Alice
    • B. ecilA
    • C. Alice lice ice ce e
    • D. lice ice ce e
    • Discuss
    • 7. 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
    • 8. 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
    • 9. 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
    • 10. 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


    Comments

    There are no comments.

Enter a new Comment