Answers for "recursive function for average in c"

C
1

recursive function for average in c

#include<stdio.h>
 
// Function Definition of findMean function
float findMean(int A[], int N)
{
    if (N == 1)
        return (float)A[N-1];
    else
        return ((float)(findMean(A, N-1)*(N-1) +
                                    A[N-1]) / N);
}
 
// Main Calling Function
int main()
{
    float Mean = 0;
    int A[] = {1, 2, 3, 4, 5};
    int N = sizeof(A)/sizeof(A[0]);
    printf("%.2f\n", findMean(A, N));
    return 0;
}
Posted by: Guest on August-21-2021

Code answers related to "recursive function for average in c"

Code answers related to "C"

Browse Popular Code Answers by Language