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!

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.

...

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!

When asking for help it usually works best when you describe the problem, not just say "doesn't work" and expect us to read your mind.

To post really excellent questions, here are some guidelines (since no one bothers to read the sticky titled "Read This Before Posting A Question"

[boilerplate_help_info]

Posting requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]Do [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If anyone posts working code for you, they are a cheater. 
    If you use that code [i]you[/i] are a cheater.
[*]Do [b]not[/b] bore us with how new you are. We can tell by your code.
- Do not apologize. We were all new, and unless you are completely 
  brain dead you will get better.
- Do not ask us to "take it easy on you."
- Do not say "I don't know what's going on." That's obvious since
  you posted for help. Use that time wisely by [b]explaining[/b] as best 
  you can so we can help.
[*][b]Do not post your requirements and nothing else. [/b]We view that as a lazy do-nothing student that wants us to do their work for them. That's cheating and we [i]will[/i] be hard on you.
[*]Do not attach files except when absolutely necessary. Most of us are not going to download file.  Add the information to your post.
[*][b]Do not tell us how urgent it is.[/b] Seriously, for us there is no urgency at all. Many that can help will ignore any URGENT or ASAP requests.
[/list]
Think more about your next post so we don't have to play 20 questions to get the info we need to help you.

[/boilerplate_help_info]

I adjusted the Indentation of the format of the program so it is more readable.

The Coding below accepts 20 random integers ,stores them into arrays location 0 to 19 and allows the user to search for the integers as many times as they would like until they are ready to exit.

#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;
}

After the user types 1 or 0 to continue to the next section of the coding, a window opens stating that there is a problem occurring with the program. Ideally, i am unsure whether or not my compiler is the problem or not but i doubt it, because it is likely my novice skills in c programming.

The case choices does not run after the input of the integers 0 or 1.

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;
}

The case choices does not run after the input of the integers 0 or 1.

You're missing '&'before 'choice' in your 'scanf' statement .

scanf("%d",&choice);

and another(important!) thing,look at this

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);//well, that's stupid!
}

You have to assign values to the array

scanf("%d",&Array[i]);//like this
// ..or like this
Array[i]=number

Good Luck! with the rest of the code for searching and all that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.