output

my program is to find the largest pallindrome made by two 3-digit number.I didn't find where i've done wrong but i didn't get any output.In my code whenever i replace 900 with 90 my cout runs but without replacement it didn't.
i'm new at this c++ thing so please help me.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<iostream>
#include<conio.h>

using namespace std;

class pallindrome{
public :

void largestpallindrome()
{
int a,b;
int z,num;
for(a=999;a>900;a--)
{
for(b=999;b>900;b--)
{
z = a*b;
num=z;

int sum=0,r;
while(z!=0)
{

r=z%10;
sum=sum*10+r;
z=z/10;
}
if(num==sum)
cout<<sum<<endl;

break;
}
}
}
};

int main()
{
pallindrome o;
o.largestpallindrome();
getch();
return 0;
}
Last edited on
The break at line 31 doesn't help.
if i just remove the break statement .....still it dosen't work.
if i just remove the break statement .....still it dosen't work.

The title of this thread is "Output". The current code gives none. Temporarily comment out the break statement and this is the output:
906609
886688
888888
861168
888888
861168
886688
824428
906609
819918
824428
819918


Hence, there is a very big clue there. The problem is in that area of the code.

Let me add then that the other half of the answer is the if statement at line 28. It needs the addition of braces { and } to control its scope.
Last edited on
ohh thanx for ur help... i really needed that.
Topic archived. No new replies allowed.