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

C Programming :: Pointers

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

     

  2. A.

    448, 4, 4

    B.

    520, 2, 2

    C.

    1006, 2, 2

    D.

    Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What will be the output of the program?

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

  4. A.

    2, 3

    B.

    2, 0

    C.

    2, Garbage value

    D.

    0, 0

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the output of the program ?

    #include 
     int main() 
     {    
         char *str;   
         str = "%d\n";   
         str++;     
         str++;   
         printf(str-2, 300);     
         return 0;
     } 
    

  6. A.

    No output

    B.

    30

    C.

    3

    D.

    300

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What will be the output of the program ?

    #include 
     int main() 
     {   
       printf("%c\n", 7["FRESHERGATE"]);
       return 0;
     } 
    

     

  8. A.

    Error: in printf

    B.

    Nothing will print

    C.

    print "X" of FRESHERGATE

    D.

    print "7"

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output of the program ?

    #include 
     int main()
     {
         char str[] = "peace";  
         char *s = str;     
         printf("%s\n", s++ +3);     
         return 0; 
     } 

     

  10. A.

    peace

    B.

    eace

    C.

    ace

    D.

    ce

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the program ?
    
     int main()
     {
        char *p;
        p="hello";
        printf("%s\n", *&*&p);
        return 0;
    }
  12. A.

    llo

    B.

    hello

    C.

    ello

    D.

    h

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the program assuming that the array begins at location 1002?

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

  14. A.

    1002, 2004, 4008, 2

    B.

    2004, 4008, 8016, 1

    C.

    1002, 1002, 1002, 1

    D.

    Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What will be the output of the program ?

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

  16. A.

    5

    B.

    25

    C.

    125

    D.

    Garbage value

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What will be the output of the program ?

    #include
      int main() 
      {    
          char str1[] = "fresher";   
          char str2[] = "GATE";    
          char *s1 = str1, *s2=str2;     
          while(*s1++ = *s2++)          
              printf("%s", str1);      
    
          printf("\n");  
          return 0;
     } 
    

     

  18. A.

    fresherGATE

    B.

    BfresBherGATE

    C.

    fresher

    D.

    (null)

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What will be the output of the program ?

     #include
     #include 
    
     int main()
     {     
        int i, n;  
        char *x="Alice";   
        n = strlen(x);   
        *x = x[n];  
        for(i=0; i"%s ", x);    
            x++;     
        }    
        printf("\n", x);    
        return 0;
     } 
    

  20. A.

    Alice

    B.

    ecilA

    C.

    Alice lice ice ce e

    D.

    lice ice ce e

    View Answer

    Workspace

    Discuss Discuss in Forum