Ok I have just ended up talking to myself on this thing. I forgot to put two = in the if statement (n1==n2).
[old]Nevermind about the "I can figure it out." I want it to tell me if I enter the first number I entered more than once. It tells me the number is repeated 9 times no matter what.
This is the old post if anyone is interested.
Ok, I forgot "using namespace std;", so nevermind. Just incase you were wondering, it does not work properly, but I can figure that part out.
I am try to write a simple programe. You enter ten numbers, and it tells you if you entered the first number you entered more than once.[/old]
[old]Nevermind about the "I can figure it out." I want it to tell me if I enter the first number I entered more than once. It tells me the number is repeated 9 times no matter what.
Code:
#include <iostream>
using namespace std;
int main()
{
int n1, n2, i, a;
i=2;
a=0;
cout<<"Enter Number 1"<<endl;
cin>>n1;
while (i<11)
{
cout<<"Enter Number "<<i<<endl;
cin>>n2;
if (n2=n1)
{
a=a+1;
}
i=i+1;
}
if (a>0)
{
cout<<n1<<" is repeated "<<a<<" times"<<endl;
}
else
{
cout<<n1<<" is not repeated"<<endl;
}
return 0;
}
This is the old post if anyone is interested.
Ok, I forgot "using namespace std;", so nevermind. Just incase you were wondering, it does not work properly, but I can figure that part out.
I am try to write a simple programe. You enter ten numbers, and it tells you if you entered the first number you entered more than once.[/old]