Home / C Programming / Pointers :: Find Output of Program

C Programming :: Pointers

  1. What will be the output of the program ?

    #include 
    
     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; 
    } 
    

     

  2. A.

    ink

    B.

    ack

    C.

    ite

    D.

    let

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What will be the output of the program ?

    #include 
    
     int main()
     {
         int i=3, *j, k;  
         j = &i;   
         printf("%d\n", i**j*i+*j);  
         return 0;
     }
    

  4. A.

    30

    B.

    27

    C.

    9

    D.

    3

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the output of the program ?

    #include 
     
     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; 
     } 
    

  6. 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

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What will be the output of the program ?

    #include
     
     int main()
     {
         char str[20] = "Hello";  
         char *const p=str;   
         *p='M';     
         printf("%s\n", str);   
         return 0;
     } 
    

  8. A.

    Mello

    B.

    Hello

    C.

    HMello

    D.

    MHello

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output of the program If the integer is 4bytes long?

    #include 
     int main()
     {
         int ***r, **q, *p, i=8;  
         p = &i;    
         q = &p;   
         r = &q;    
        printf("%d, %d, %d\n", *p, **q, ***r);     
        return 0;
     } 
    

  10. A.

    8, 8, 8

    B.

    4000, 4002, 4004

    C.

    4000, 4004, 4008

    D.

    4000, 4008, 4016

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the program ?

    #include  
    int main() 
    {    
       char *str;    
       str = "%s";    
       printf(str, "K\n");     
       return 0; 
    } 
    

  12. A.

    Error

    B.

    No output

    C.

    K

    D.

    %s

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the program ?

    
    #include 
    int *check(static int, static int); 
     int main()
     {
          int *c; 
          c = check(10, 20);  
          printf("%d\n", c);    
          return 0; 
     } 
    int *check(static int i, static int j)
     {    
          int *p, *q;   
          p = &i;    
          q = &j;   
          if(i >= 45)  
            return (p);  
       else       
            return (q);
     } 
    

  14. A.

    10

    B.

    20

    C.

    Error: Non portable pointer conversion

    D.

    Error: cannot use static for function parameters

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What will be the output of the program if the size of pointer is 4-bytes?

    #include 
    
     int main() 
     {
         printf("%d, %d\n", sizeof(NULL), sizeof(""));    
         return 0; 
     }     
    

     

  16. A.

    2, 1

    B.

    2, 2

    C.

    4, 1

    D.

    4, 2

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What will be the output of the program ?

    #include 
     
     int main()
     {
         void *vp;    
         char ch=74, *cp="JACK";  
         int j=65;    
         vp=&ch;  
         printf("%c", *(char*)vp);     
         vp=&j;     
         printf("%c", *(int*)vp); 
         vp=cp;    
         printf("%s", (char*)vp+2);  
         return 0;
     }
    

  18. A.

    JCK

    B.

    J65K

    C.

    JAK

    D.

    JACK

    View Answer

    Workspace

    Discuss Discuss in Forum


  19.  

    #include
    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;
     }
    

  20. A.

    8, 10

    B.

    10, 2

    C.

    8, 1

    D.

    Garbage values

    View Answer

    Workspace

    Discuss Discuss in Forum