0

Original Post

Guys ive figured it out but when i type the same numbers again still it was not rejected even though i already insert it in the index and it limit only for 5 index...heres the code

    #include <iostream>

    using namespace std;
    int main()
    {
    int x,y;
    int number;
    int arr[5];

    for (x=0;x<=5;x++)
    {
        cout<<"enter nmber"<<endl;
        cin>>number;
    bool replace=true;
    for (y=0;y<x;y++)
    {
       if (number == arr[y])
       {

          replace=false;
          break;
       }
    }

    if (replace)
    {
          arr[x]=number;
          x++;
    }

}


return 0;

}
Community
  • 1
  • 1
jboy
  • 11
  • 3

0 Answers0