Sunday, July 12, 2009

How to write a c program to find average & sum of n numbers by calling functions with out using printf &scanf?

u dont need printf and scanf to get the sum/average of n numbers.





double average (int *numbers, int n)


{


int i;


double ave = 0;


for (i=0; i%26lt;n; i++)


ave += numbers[i];


if (n %26gt; 0) return ave / n;


return 0;


}





int sum (int *numbers, int n)


{


int i;


int sum = 0;


for (i=0; i%26lt;n; i++)


sum += numbers[i];


return sum;


}

easter cards

No comments:

Post a Comment