I need to make a program to check if the entered number is palindrome or not i.e. if u take a number and reverse it it will be the same old number for example if u take 121..then if u reverse the number it will be 121 and so 121 is a palindrome number.

i wrote a program to check if a number is palindrome or not but it is not working properly :cry: ...Can any1 plz tell me wat is wrong..

The program which I wrote is below:-

#include<iostream.h>
#include<conio.h>

void main()

{
	
	int n, x, m=0;

	cout<<"Enter any number"<<endl;
	cin>>n;

	while(n>0)

	{

		m*=10;

		x=n%10;

		m+=x;

		n/=10;

	}

	if(m==n)

	cout<<"The entered number is a palindrome number"<<endl;

	else

	cout<<"The entered is not a palindrome number"<<endl;

	getch();

}

>if(m==n)
n is zero at this point, remember? Use a copy of n for your loop counter so that the original value is preserved.

Hey thanx a lot Narue...my program is working Perfectly now!! :cheesy:

And once again Thanx a lot....

Just a helpful hint here on the forum for you:

Cn u plz not use chat spk here? Wat do u want 2 do that for? U got all d time in d world 2 make a post, so there's no need 2 uz chat spk n here.

Please, for all of our eyes' sakes, spend about 30 seconds more on your post, and spell words in a non-lame fashion.

kthxbye! :D

tx alx, i culdnt ha sd it b8ter mself

Your program is write up to if(m==n)

in the above program n will become zero
after the loop. So assign n value to any other variable,then compare with m.

Congratulations, muraliaa! It took you only four years to come up with the same answer as me.

This thread is so old, it saw the creation of the previous LHC :)

commented: haha :)! +4

Congratulations, muraliaa! It took you only four years to come up with the same answer as me.

Some people are just a little slow :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.