Home / C Programming / Complicated Declarations :: Find Output of Program

C Programming :: Complicated Declarations

  1. What will be the output of the program?

     #include 
     
     int main()
     {    
         char far *near *ptr1;   
         char far *far *ptr2;    
         char far *huge *ptr3;       
         printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));  
         return 0;
     }
    

     

  2. A.

    4, 4, 8

    B.

    4, 4, 4

    C.

    2, 4, 4

    D.

    2, 4, 8


  3. What will be the output of the program in DOS (Compiler - Turbo C)?

     #include
     double i; 
    
     int main() 
     {   
        (int)(float)(char) i;       
        printf("%d", sizeof((int)(float)(char)i));  
        return 0; 
     } 
    

  4. A.

    1

    B.

    2

    C.

    4

    D.

    8


  5. What will be the output of the program?

      #include
      int main()
      {   
         char huge *near *far *ptr1;       
         char near *far *huge *ptr2;     
         char far *huge *near *ptr3;     
         printf("%d, %d, %d\n", sizeof(**ptr1), sizeof(ptr2), sizeof(*ptr3));  
         return 0; }
    

  6. A.

    4, 4, 4

    B.

    2, 2, 2

    C.

    2, 8, 4

    D.

    2, 4, 8


  7. What will be the output of the program (in Turbo C under DOS)?

    #include 
    
     int main() 
     {   
         char huge *near *far *ptr1;        
         char near *far *huge *ptr2;     
         char far *huge *near *ptr3;     
         printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));   
         return 0; } 
    

  8. A.

    4, 4, 8

    B.

    2, 4, 4

    C.

    4, 4, 2

    D.

    2, 4, 8


  9. What will be the output of the program?

    #include
     typedef void v; 
     typedef int i;
     int main()
     {   
         v fun(i, i); 
         fun(2, 3);   
         return 0; 
    }
    v fun(i a, i b)
     {    
          i s=2;   
          float i;    
          printf("%d,", sizeof(i));       
          printf(" %d", a*b*s);
     } 
    

  10. A.

    2, 8

    B.

    4, 8

    C.

    2, 4

    D.

    4, 12


  11. What will be the output of the program?

    #include 
     int main() 
     {   
        char huge *near *far *ptr1;          
        char near *far *huge *ptr2;     
        char far *huge *near *ptr3;     
        printf("%d, %d, %d\n", sizeof(ptr1), sizeof(*ptr2), sizeof(**ptr3)); 
        return 0;
     } 
    

  12. A.

    4, 4, 4

    B.

    2, 4, 4

    C.

    4, 4, 2

    D.

    2, 4, 8


  13. What will be the output of the program?

    #include
     typedef unsigned long int uli;   
     typedef uli u; 
    
     int main() 
     {   
         uli a;  
         u b = -1;  
         a = -1;   
         printf("%lu, %lu", a, b);       
         return 0;
     } 
    

  14. A.

    4343445454, 4343445454

    B.

    4545455434, 4545455434

    C.

    4294967295, 4294967295

    D.

    Garbage values


  15. What will be the output of the program in DOS (Compiler - Turbo C)?

     #include
     double i;
     
     int main() 
     {   
        (int)(float)(char) i;          
        printf("%d",sizeof(i));     
        return 0;
     } 
    

  16. A.

    4

    B.

    8

    C.

    16

    D.

    22


  17. What will be the output of the program under DOS?

     #include
    
      int main() 
      {  
         char huge *near *far *ptr1;        
         char near *far *huge *ptr2;     
         char far *huge *near *ptr3;     
         printf("%d, %d, %d\n", sizeof(ptr1), sizeof(**ptr2), sizeof(ptr3)); 
         return 0;
         } 
    

  18. A.

    4, 4, 4

    B.

    4, 2, 2

    C.

    2, 8, 4

    D.

    2, 4, 8


  19. What will be the output of the program?

    #include 
    
     int main() 
     {   
         struct s1  
         {       
             char *z;    
          int i;   
          struct s1 *p;    
          }; 
          static struct s1 a[] = {{"Nagpur", 1, a+1} , {"Chennai", 2, a+2} ,                              {"Bangalore", 3, a} }; 
         struct s1 *ptr = a;       
         printf("%s,", ++(ptr->z));     
         printf(" %s,", a[(++ptr)->i].z);     
         printf(" %s", a[--(ptr->p->i)].z); 
         return 0; 
     } 
    

  20. A.

    Nagpur, Chennai, Bangalore

    B.

    agpur, hennai, angalore

    C.

    agpur, Chennai, angalore

    D.

    agpur, Bangalore, Bangalore