I cant get my function code to work. Its should return an average of however many numbers are entered, but it always returns 775863 no matte what... can anyone tell me whats wrong?
#include <stdio.h>
int avg(int av[], int y, int x, int z);
int main(){
int x=0;
int av[50];
int y=0;
int z=0;
printf("Enter the number or numbers to average\n\n");
scanf("%d", &x);
do
{
y++;
printf("\n");
scanf("%d", av[x]);
}
while (y<x);
printf("\n\n\n%d", avg(av, y, x, z));
return 0;}
int avg(int av[], int y, int x, int z)
{
y=0;
do
{
y++;
z = z+av[y];
}
while (y<x);
return z/x;
}