Here's how:
Code:
#include <stdio.h>
int main (void)
{
int n, sum;
printf("?: Specify a number of values.\n\ni: The x variables are by default started at 0 and your desired number should be the highest x variable. If any slots in the x array are not available, you should leave the frequency fields at 0.\n\nTherefore, your highest value of x please: ");
scanf("%i", &n);
printf("i: Success: Array size set to contain %i elements (including 0)\n\n", n);
int size = n, values[size];
for ( size = 0; size < n; ++size )
{
printf("?: For x = %i, f = ?: ", size);
scanf("%i", &values[size]);
printf("i: Success: When x = %i, f = %i\n\n", size, values[size]);
}
printf("i: Now printing a table of data . . .\n\n");
printf("| x (Variable) | f (Frequency) |\n");
printf("-----------------------------------------\n");
for ( size = 0; size < n; ++size )
{
printf("| %3i | %3i |\n", size, values[size]);
}
printf("i: END\n");
int values_copy = values, sum_up;
/*add all values so as to find the mean*/
for ( size = 0; sum_up = 1; sum_up < n; ++sum_up )
{
sum = values_copy[size] + values_copy[sum_up];
}
printf("int sum = %i\n", sum);
return 0;
}
But the last for loop is dead. Always complainin'. This program is meant to find the mean of a set of unnamed number of values.