Determine array values

everytimes enter a new number
if the new number belongs to any number in oldnumber
program will show "the number is already exit"
but everytimes i enter number "1" to newnumber
the program will show both of the if else statements
i know where is the wrong but i don't how to fix this problems

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string oldnumber[5]={"1","2","3"};
	string newnumber[5];
	int size=3;

	for (int i=size;i<10;i++)
		{
			cout<<"enter  a  new number:";
			cin>>newnumber[size];
				for (int j=0;j<size;j++)
			{
				if (newnumber[size]==oldnumber[j])
					{
						cout<<"your account number is already exit";
						
					}
				else if (newnumber[size]!=oldnumber[j])
					{
						cout<<"the number you enter is"<<newnumber[size]<<endl;
						
					}
				}
	}

	
	return 0;
}
on line 21: you can omit the if statement because else suffice.

from line 13 you need to replace size with i othewise you compare the first elements only and never the newly entered
Topic archived. No new replies allowed.