top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How many parameter can we pass as argument in function ?

+2 votes
414 views

How many parameters can we pass as argument in function? Is there any limit ?
If yes , Please explain the reason.

posted Oct 23, 2013 by Vikas Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

3 Answers

+2 votes

Yes there is a Limit as per the reference
— Parameters in one function definition [256].
— Arguments in one function call [256].

answer Oct 23, 2013 by Luv Kumar
–1 vote

Argument fall under function which is fall in memory stack. So, I guess the limit will be be size or around the size of stack. Let we get comments from others.

answer Oct 23, 2013 by sivanraj
–1 vote
#include <stdarg.h>
#include <stdio.h>

/* this function will take the number of values to average
   followed by all of the numbers to average */
double average ( int num, ... )
{
    va_list arguments;                     
    double sum = 0;

    /* Initializing arguments to store all values after num */
    va_start ( arguments, num );           
    /* Sum all the inputs; we still rely on the function caller to tell us how
     * many there are */
    for ( int x = 0; x < num; x++ )        
    {
        sum += va_arg ( arguments, double ); 
    }
    va_end ( arguments );                  // Cleans up the list

    return sum / num;                      
}

int main()
{
    /* this computes the average of 13.2, 22.3 and 4.5 (3 indicates the number of values to average) */
    printf( "%f\n", average ( 3, 12.2, 22.3, 4.5 ) );
    /* here it computes the average of the 5 values 3.3, 2.2, 1.1, 5.5 and 3.3
    printf( "%f\n", average ( 5, 3.3, 2.2, 1.1, 5.5, 3.3 ) );
}
answer Oct 23, 2013 by anonymous
...