CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    19

    Need help with basic array program. Won't run.

    I made a program that reads in20 numbers, each between 10 to 100 and if a user inputs a number not in that range they are asked to re-input. After reading in all the values, I need to display all the unique vclues.
    Thanks!

    Code:
    #include <iostream>
    using namespace std;
    
    int counter = 0;
    int num = 0;
    
    int main ()
    {
    
    int array = new array [20];
    
    while(counter <= 20){
    cin << num;
    
     if(num>=10 && num<=100){
     array[counter] = num;
     counter++;
     }
    
    
     else {
     cout << "Enter a number between 1 and 10";
    }
    
    
    }
    
    for(int x=0; x<=20; x++)
    {
    cout << array[x];
    }
    return 0;
    }

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Need help with basic array program. Won't run.

    What is your question about your post ?

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Need help with basic array program. Won't run.

    I would have an array size of 90 with all elements initialized to 0.

    Given that as a starting point, think about what you'd need to change.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured