[try Beta version]
Not logged in

 
whats wrong with this programme

Apr 15, 2009 at 12:36pm
can some 1 help me check where is the error...the logic shld b correct

#include <iostream>
#include <cstdlib>
using namespace std;

bool palindromes(long no);
int main ()
{
long num,no;
cout<<"Input a number to check if it is palindrome -> ";
cin>>num;

palindromes(long no);

if (no = true)
{
cout<<num;
cout<<" is a palindrome.";
}

else
{
cout<<num;
cout<<" is not a palindrome.";
}

cout<<endl;
system("pause");
return 0;
}

bool palindromes(long no)
{
long num, quation, remainder,RN;

quation=num;
RN=0;
do
{
remainder=quation%10;
quation=quation/10;

RN=RN*10+remainder;
}

while (quation!=0);

if (num==RN)
{
return true;
}

else
{
return false;
}
}
Apr 15, 2009 at 12:45pm
Please use [code][/code] tags
You are calling 'palidromes' in a wrong way:
1
2
3
4
5
long num,no;
cout<<"Input a number to check if it is palindrome -> ";
cin>>num;

palindromes(long no);// <-- ERROR 

call it this way: palindromes(num);
Apr 15, 2009 at 12:55pm
i change le still gt error
Apr 15, 2009 at 1:02pm
You also have errors like ...
1
2
3
4
5
if (no = true) // should be ==
{
cout<<num;
cout<<" is a palindrome.";
}
Apr 15, 2009 at 1:04pm
in main: if (no = true) should be if (palindromes(num))
in palindromes: quation=num; should be quation=no;
1
2
3
4
5
6
7
8
9
if (num==RN)
{
return true;
}

else
{
return false;
}
should be return no==RN;
Apr 15, 2009 at 1:08pm
its a function qn and i nid to return true and false to the palindromes(long num)
Apr 16, 2009 at 2:59pm
some 1 help me
Apr 17, 2009 at 3:15am
What kind of error(s) do you have? What does your compiler say when you try to build? also you should post your updated code, and put it in between code tags.
Topic archived. No new replies allowed.