Can someone help me with my program. I have the code but there are some logical errors. The program should contain 100 numbers that have a menu, first the user should input a number then the menu will show: 1. it adds again a number, 2. it displays all the inputted numbers, 3. it will display the sum of all the numbers, 4. the program will exit. This is the code i had created i don't know I'm correct with the code in the case 2,3,4.
#include<stdio.h>
void main(void)
{
int sub,total=0,choice;
int numbers[100];
add:
do{
clrscr();
printf("Key-in numbers:\n\n");
for(sub=0;sub<100;sub++)
{
scanf("%d",&numbers[sub]);
printf("MENU");
printf("[1] Add Number.");
printf("[2] Display all numbers.");
printf("[3] Display Total.");
printf("[4] Exit.");
printf("Select your choice: ");
scanf("%d",&choice);
switch(choice){
case 1:
goto add;
break;
case 2:
printf("Number [%d]: %d",sub,numbers[sub]);
break;
case 3:
total=total+numbers[sub];
printf("\nTotal: %d.",total);
break;
case 4:
return 0:
default:
printf("Invalid Choice!");
getch();
goto add;
}
}
}while(choice!=3);
getch();
return 0;
}