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

C Programming :: Functions

  1. What will be the output of the program?

    #include 
     
     int addmult(int ii, int jj)
     {    
         int kk, ll;    
         kk = ii + jj;     
         ll = ii * jj;    
         return (kk, ll); 
     }
    
    int main()
    {    
        int i=3, j=4, k, l;  
        k = addmult(i, j);   
        l = addmult(i, j);   
        printf("%d %d\n", k, l);   
        return 0; 
    }
    

     

  2. A.

    12 12

    B.

    No error, No output

    C.

    Error: Compile error

    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What will be the output of the program?

    #include
     int i;
     int fun1(int); 
     int fun2(int); 
    
     int main() 
     {    
        extern int j;    
        int i=3;     
        fun1(i);    
        printf("%d,", i);    
        fun2(i);   
        printf("%d", i);    
        return 0;
     }
     int fun1(int j) 
     {   
        printf("%d,", ++j);  
        return 0; 
    }
    int fun2(int i)
    {   
        printf("%d,", ++i);  
        return 0; 
    }
    int j=1; 

     

  4. A.

    3, 4, 4, 3

    B.

    4, 3, 4, 3

    C.

    3, 3, 4, 4

    D.

    3, 4, 3, 4

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the output of the program?

     #include
     int func1(int);  
     
     int main() 
     {    
         int k=35;    
         k = func1(k=func1(k=func1(k)));   
         printf("k=%d\n", k);    
         return 0;
     }
     int func1(int k)
     {     
         k++;  
         return k; 
     } 

     

  6. A.

    k=35

    B.

    k=36

    C.

    k=37

    D.

    k=38

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What will be the output of the program?

    #include 
     
     int addmult(int ii, int jj) 
      {  
          int kk, ll;    
          kk = ii + jj;   
          ll = ii * jj;     
          return (kk, ll);
      }
      
     int main() 
     {     
         int i=3, j=4, k, l;   
         k = addmult(i, j);    
         l = addmult(i, j);     
         printf("%d, %d\n", k, l);    
         return 0;
     }

     

  8. A.

    12, 12

    B.

    7, 7

    C.

    7, 12

    D.

    12, 7

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. If int is 2 bytes wide.What will be the output of the program?

    #include  
     void fun(char**); 
    
     int main() 
     {    
         char *argv[] = {"ab", "cd", "ef", "gh"};  
         fun(argv);  
         return 0;
     } 
     void fun(char **p)
     {   
         char *t;    
         t = (p+= sizeof(int))[-1];    
         printf("%s\n", t);
     } 
    

     

  10. A.

    ab

    B.

    cd

    C.

    ef

    D.

    gh

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the program?

    #include 
     int fun(int(*)());
    
     int main()
     {   
         fun(main);   
         printf("Hi\n");  
         return 0;
     }
     int fun(int (*p)()
     )     
         printf("Hello ");   
         return 0;
     } 

     

     

  12. A.

    Infinite loop

    B.

    Hi

    C.

    Hello Hi

    D.

    Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the program?

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

     

     

  14. A.

    5

    B.

    4

    C.

    Error

    D.

    Garbage value

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What will be the output of the program?

    #include
     int fun(int);
     int main() 
     {   
       float k=3;    
       fun(k=fun(fun(k)));  
       printf("%f\n", k);   
       return 0; 
     } 
     int fun(int i) 
     {    
        i++;  
        return i; 
     } 

     

  16. A.

    5.000000

    B.

    3.000000

    C.

    Garbage value

    D.

    4.000000

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What will be the output of the program?

    
     #include
     #include 
    
      int main() 
      {    
         int i=0;     
         i++;   
         if(i5)     
         {        
            printf("FRESHERGATE");     
            exit(1);       
            main();    
         }
         return 0; 
     } 

     

  18. A.

    Prints "FRESHERGATE" 5 times

    B.

    Function main() doesn't calls itself

    C.

    Infinite loop

    D.

    Prints "FRESHERGATE"

    View Answer

    Workspace

    Discuss Discuss in Forum