hey everyone on Daniweb, I'm liuhh00 in need of some dire suggestions for my program.
I can't seem to solve why my program is not working right after i select my choice for case.
The program is suppose to accept any 20 random integers, store them and allow the user to tranverse as many as they would like to.
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main()
{
int i= 1;
int number, integer,choice;
int ArrayN[20];
for(i=0;i<20;i++)
{
printf("Enter 20 Integers\n");
scanf("%d", &number);
printf("ArrayN[%d]=%d\n",i,number);
}
printf("\n");
getch();
do
{
system("cls");
printf("Type 0 to Exit or 1 to Continue then press Enter\n");
scanf("%d",choice);
switch(choice)
{
case 0:
exit(EXIT_SUCCESS);
break;
case 1:
printf("What Number would you like to search for?\n");
scanf("%d", &integer);
if(integer==number)
{
printf("\nYou Have Guessed Right");
printf("\nYou have found your number at location %d",i);
}
else
{
printf("\nOh.....");
printf("\n Try Again?");
}
break;
default:
printf("\nFollow Instructions...");
exit(EXIT_SUCCESS);
break;
}
}
while(integer!=0);
return 0;
}
open to any critique as well. I am just looking towards improving the program's efficiency.
I am currently working to make the program run as long as user wants until they are ready to exit as well.
I use Codeblocks as my compiler.
Thanks!