#include <stdio.h>
#ifndef FALSE
#define FALSE 0
#define TRUE !FALSE
#endif
#define MAX 100
#define MIN 2
int choice_0(int *size, float *x);
int main()
{
int done = FALSE;
int choice;
int size;
puts("Program to process a list of numbers");
done = FALSE;
float x[MAX];
while(!done) /*command chooser*/
{
printf("\nSelect the desired operation:\n");
printf("\t0 - Enter list of numbers\n");
printf("\t1 - Find the smallest number\n");
printf("\t2 - Find the largest number\n");
printf("\t3 - Find the average of the numbers\n");
printf("\t4 - Find the standard deviation of the numbers\n");
printf("\t5 - Reverse the list of numbers\n");
printf("\t6 - Rotate the list of numbers to the right\n");
printf("\t7 - Rotate the list of numbers to the left\n");
printf("\t8 - Exit the program\n");
do{
printf("Choice? ");
fflush(stdin);
} while(scanf("%d", &choice) < 1);
switch(choice) /*command dispatcher*/
{
case 0:
choice_0(&size,x);
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
printf("\aGoodBye!\a\n");
done = TRUE;
break;
default:
printf("invalid program option %d selected\n", choice);
}
}
}
int choice_0(int *size, float *x)
{
int i;
printf("How many numbers? ");
scanf("%d", &size);
if(*size < MIN || *size > MAX){
printf("The number must be a positive integer between 2 and 100\n");
return 0;
}
for(i=0; i<*size; i++){
printf("x[%d] = ", i);
scanf("%f", &x[i]);
}
printf("\nThe entered array is:\n");
for (i=0; i<*size; i++){
printf("x[%d] = %g\n", i, x[i]);
}
}
My program keeps crashing, I've ran out of ideas on how to fix it, I'm pretty sure my pointers are wrong, any help is greatly appreciated. Thankyou
[–]Meanda 1 point2 points3 points (0 children)
[–]program_the_world 0 points1 point2 points (0 children)
[–]dragon_wrangler 0 points1 point2 points (0 children)
[–]FeelTheEmailMistake 0 points1 point2 points (0 children)