Hello there, my question is , i read upto 20 numbers from a file, then i have to sort them into, negatives, odd's and even's, then i have to display total negatives, odd's, and even's, i also have to display all the acutal values of the negatives, odd's, and even's. one problem i m getting is it's only reading 19 numbers (0 to 19), and the rest i think u can see from the output (preety messed up),

here is the input

Code:

54

5

45

4

5

-123

-232

-454

654

54

478

2221

-35

4565

-12

2

33

45

-12

-15

Here is the code

```
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin;
int arnNum[21];
//int Even[20]={0},Odd[20]={0},Neg[20]={0}; // don't know how if this line work, so commented.
int EvenCount=0,OddCount=0,NegCount=0;
fin.open("numbers2.txt");
while (fin)
{
for (int x=0;x<20;x++)
{
fin>>arnNum[x];
if (arnNum[x]>0)
{
NegCount+=1;
}
else if (arnNum[x]%2==0)
{
EvenCount+=1;
}
else if (arnNum[x]%2!=0)
{
OddCount+=1;
}
if (fin.eof ())
break;
cout<<"Total Negative numbers = "<<EvenCount<<endl;
cout<<"Total Even numbers = "<<EvenCount<<endl;
cout<<"Total Odd numbers = "<<OddCount<<endl;
cout<<x<<endl;// to check for total numbers
}
}
/*cout<<"All the Negative number are "<< // don't know how
cout<<"All the Even numbers are "<< // don't know how
cout<<"All the Odd numbers are"<< // don't know how*/
return 0;
}
```

Here is what i get as output

Code:

Total Negative numbers = 0

Total Even numbers = 0

Total Odd numbers = 0

0

Total Negative numbers = 0

Total Even numbers = 0

Total Odd numbers = 0

1

Total Negative numbers = 0

Total Even numbers = 0

Total Odd numbers = 0

2

Total Negative numbers = 0

Total Even numbers = 0

Total Odd numbers = 0

3

Total Negative numbers = 0

Total Even numbers = 0

Total Odd numbers = 0

4

Total Negative numbers = 0

Total Even numbers = 0

Total Odd numbers = 1

5

Total Negative numbers = 1

Total Even numbers = 1

Total Odd numbers = 1

6

Total Negative numbers = 2

Total Even numbers = 2

Total Odd numbers = 1

7

Total Negative numbers = 2

Total Even numbers = 2

Total Odd numbers = 1

8

Total Negative numbers = 2

Total Even numbers = 2

Total Odd numbers = 1

9

Total Negative numbers = 2

Total Even numbers = 2

Total Odd numbers = 1

10

Total Negative numbers = 2

Total Even numbers = 2

Total Odd numbers = 1

11

Total Negative numbers = 2

Total Even numbers = 2

Total Odd numbers = 2

12

Total Negative numbers = 2

Total Even numbers = 2

Total Odd numbers = 2

13

Total Negative numbers = 3

Total Even numbers = 3

Total Odd numbers = 2

14

Total Negative numbers = 3

Total Even numbers = 3

Total Odd numbers = 2

15

Total Negative numbers = 3

Total Even numbers = 3

Total Odd numbers = 2

16

Total Negative numbers = 3

Total Even numbers = 3

Total Odd numbers = 2

17

Total Negative numbers = 4

Total Even numbers = 4

Total Odd numbers = 2

18

Thanks