Home / C Programming / Variable Number of Arguments :: Discussion

Discussion :: Variable Number of Arguments

  1. Point out the error in the following program.

     #include
     #include
      fun(...);  
     
      int main() 
      {    
         fun(3, 7, -11.2, 0.66);     
         return 0; 
      } 
      fun(...)
      {    
          va_list ptr;    
          int num;   
          va_start(ptr, n);   
          num = va_arg(ptr, int);      
          printf("%d", num); 
     } 
    

  2. A.

    Error: fun() needs return type

    B.

    Error: ptr Lvalue required

    C.

    Error: Invalid declaration of fun(...)

    D.

    No error

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    There is no fixed argument in the definition fun()


Be The First To Comment