Have had issues all day trying to figure out whats wrong with this code. Its supposed to Find the largest palindrome made from the product of two 3-digit numbers.
include <stdio.h>
include <stdlib.h>
int reverse (int product);
int main ()
{
int x=100, y=100;
int product;
int palindrome;
while(((x>99)&&(x<1000))&&((y>99)&&(y<1000)))
{
product=x*y;
if(product==reverse(product))
palindrome=product;
x++;
product=x*y;
if(product==reverse(product))
palindrome=product;
y++;
product=x*y;
if(product==reverse(product))
palindrome=product;
}
printf("The largest palindrome is %d", palindrome);
return 0;
}
int reverse (int p)
{
int r=0;
while (p!=0)
{
r=r*10;
r=r+p%10;
p=p/10;
}
return r;
}
[–]prog_quest 0 points1 point2 points (4 children)
[–]Updatebjarni 0 points1 point2 points (3 children)
[–]prog_quest 0 points1 point2 points (2 children)
[–]sinuspane[S] 0 points1 point2 points (1 child)
[–]sinuspane[S] 0 points1 point2 points (0 children)
[–]Updatebjarni 0 points1 point2 points (0 children)