To find largest pallindrome number of two digit product
#include <stdio.h>
int reverse(int x){
int rev =0;
while(x!=0)
{
int rem = x%10;
rev = rev*10 + rem;
x= x/10;
}
return rev;
}
int main(){
int product,result;
int n1,n2;
for(n1=99;n1>10;n1--){
for(n2=99;n2>10;n2--){
product = n1 * n2;
result = reverse(product);
if(product == result){
printf("The largest pallindrom is %d\n",result);
break;
}
}
if(product == result){
break;
}
}
return 0;
}
Output |
Comments
Post a Comment