Palindrome numbers AT DEV C ++...?

Question:please help me with this...

because when i run it, there is always an error...

i am using Dev c++...

the program suppose to tell if the given number is a Palindrome or not...

here it is...

#include <stdio.h>
#include <conio.h>

using namespace

int palindrome(int n)
{
int x, m=0;
while(n>0)
{
x=n%10;
m*=10;
m+=x;
n/=10;
}
return m;
}

void main()
{
int n, y;

printf("Enter any number\n");

y=palindrome(n);
if(n==y)
printf("The entered number is a palindrome number ");
else
printf("The entered number is not a palindrome number ");
}

Answers:
Your code only prints output and does not accept any user input.

Try this please:

#include <iostream>
using namespace std;

int palindrome(int n)
{
int x, m=0;
while(n>0)
{
x=n%10;
m*=10;
m+=x;
n/=10;
}
return m;
}

void main()
{
int n, y;

cout<<"Enter any number"<<endl;
cin>>n;
y=palindrome(n);
if(n==y)
cout<<"The entered number is a palindrome number "<<endl;
else
cout<<"The entered number is not a palindrome number "<<endl;
}

This article contents is post by this website user, EduQnA.com doesn't promise its accuracy.



More Questions & Answers...
  • When passing or...?
  • What jobs could i get?
  • Do you agree university should keep equal number of boys and girls in classroom?
  • Seton hall?
  • Who is the most intelligent person you have ever been in clas with ?
  • My daughter wants to take her highschool classes online.?
  • Does anybody know something about area 51?
  • What is the package i can expect if i do mcse and ccna?
  • Copyright 2006-2007 EduQnA.com All Rights Reserved.