I have this programm where u put in an amound of numbers and the program calculates the median. But when i give in any number it says acces violation error?
i can't figure out the problem
Code:
/* INCLUDES: */#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <math.h>
/*DECLARATIONS*/
int nGem(int);
/* MAIN PROGRAM: */
int main(void)
{
int n;
int nAantal;
int nB;
int nInvoer;
int nArray[20]={1};
printf("Hoeveel weerstanden wilt u invoeren?");
scanf("%d", &nAantal);
for (nB = 0; nB<nAantal; nB++)
{
printf("Voer een aantal weerstanden in");
scanf("%d", nArray[nB]);
}
n = nGem(nInvoer);
printf("%d", &n);
return(0);
}
int nGem(int nInvoer)
{
char chAgain = 'y';
int nAantal;
int nSum = 0;
int nAverage = 0;
int nB;
int nU ;
int nArray[100] = {1};
for (int i = 0; i < 10; ++i)
{
nSum+=nArray[i];
}
nAverage = nSum/10;
return nAverage;
}