Can you please tell me what i did wrong?
I have to enter some numbers and then to find out if they are palindromes or not,and if they are,how many of them are.
#include <iostream>
usingnamespace std;
int main() {
int num,n,c,rev=0,x;
int i=1,s=0;
cout << "Please enter the maximum of numbers you want to enter\nmax=";
cin >> num;
cout << "Now enter the numbers.\n";
while (i<=num) {
cout << "x= ";
cin >> x;
while (x>0){
c=x%10;
rev=rev*10+c;
x=x/10;
}
n=x;
if (rev==n) s++;
i++;
}
cout << "The total of palindromes is " << s << endl;
return 0;
}
On line 23 you have n = x but what is n? I suppose n was meant to have recorded the value of x before x entered the loops, so you need an additional statment b/w your current lines 17 and 18: n = x;