well ,this is a program to find whether the given no is PALINDROME,its not giving the correct output.Please HELP!!!!

Write your question here.

using namespace std;
#include<iostream>
#include<math.h>

int main()
{
int p,r[100],n,t,sum=0;
cout<<"give any no. ,p=";
cin>>p;
while(p!=0)
{
for(n=0;n<100 ;n++)
{
r[n]=p%10;
p=p/10;
}
t=n;
}
for(t,n=0;t>0;n++,t--)
{
sum=sum+pow(10,t)*r[n];
}
if(sum==p)
cout<<"palindrom";

else
cout<<"no";
//getch();
}
Do you know what the code is doing? Where is it calculating something you don't understand?
PLEASE use the code tag

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
using namespace std;
#include<iostream>
#include<math.h>
int main()
{
    int p,r[100],n,t,sum=0;
    cout<<"give any no. ,p=";
    cin>>p;
    while(p!=0)
    {
        for(n=0;n<100 ;n++)
        {
            r[n]=p%10;
            p=p/10;
        }
        t=n;
    }
    for(t,n=0;t>0;n++,t--)
    {
        sum=sum+pow(10,t)*r[n];
    }
    if(sum==p)
    cout<<"palindrom";
    else
    cout<<"no";
    //getch();
}


Have you tried writing an algorithm out on paper?
Topic archived. No new replies allowed.