I am trying to write a program in C to calculate the mean of a set of numbers. Of course, the number of values is up to the user, so I have a variable no_values that will get the number of values by scanf and an array values_x for variables and another values_f for frequency. I have scanned the chapter in my Programming in C book by Stephen Kochan but can't find this stuff. Here's the source code:
Code:
#include <stdio.h>
int main () {
printf("\n\nAn Application to find the mean of a set of numbers");
int no_values, comp_values;
printf("\n\nHow many values will you be entering? ");
scanf("%i", &no_values);
comp_values = no_values -1;
int array_values;
int values_x[array_values];
int values_f[array_values];
printf("\nPlease start entering your values");
printf("| x | f |\n\n");
for ( comp_values == 1; comp_values < no_values; ++comp_values ) {
printf("x Variable: ");
scanf("%i", &values_x[array_values]);
printf("f Frequency: ");
scanf("%i", &values_f[array_values]);
printf("|%i |%i |\n\n", values_x, values_f);
}
return 0;
}