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...