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

Discussion :: Variable Number of Arguments

  1. Point out the error in the following program.

     #include
     #include
    
      int main() 
      {  
           void display(int num, ...);     
           display(4, 12.5, 13.5, 14.5, 44.3);   
           return 0; 
      }
      void display(int num, ...) 
      {    
          float c; int j;   
          va_list ptr;     
          va_start(ptr, num);    
          for(j=1; j      
              printf("%f", c); 
         } 
     }
    
    

  2. A.

    Error: invalid va_list declaration

    B.

    Error: var c data type mismatch

    C.

    No error

    D.

    No error and Nothing will print

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    Use double instead of float in float c;


Be The First To Comment