Start New Discussion within our Software Development Community

:rolleyes: my program is not running right I,m not sure what is wrong with it the output is always true can someone help me

/// Robert H Ramzy IV
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <iostream>
#include <string>
#include <iomanip>
#include <ctype.h>
#include <cmath>
int number;
bool results ;
usingnamespace std;
bool ISNUMPALINDROME (int num)
{
int PWR = 0;

if (num < 10 )
{
return true;
}
else
{
while (num / static_cast<int> (pow(10,PWR)) >= 10)
{
PWR++;
}
while (num >= 10)
{
int TENTOPWR = static_cast<int>(pow(10,PWR));
if (( num /TENTOPWR) != (num % 10))
{
return false;
}
else
{
num = num % TENTOPWR ;
num = num / 10 ;
PWR = PWR - 2;
}
} // end of while loop
return true;
} //end else statement
}//end of function
int main ()
{
cout << " This Program is designed to determine if a non-negative number is a Palindrome Number ? "<<endl;
cout << " A number is a Palindrome Number if it can be written in reverse and it is still the same number "<<endl;
cout << " A few examples of this are numbers like 5,22,111,13231 "<<endl<<endl;
cout << " Please enter a number to be evaluated "<<endl<<endl;
cin >> number;
ISNUMPALINDROME (number);
results = ISNUMPALINDROME;
cout << "results are egual to = " << results <<endl<<endl;
if (results == true )
{
cout << " The number is a Palindrome Number "<<endl;
}
else
{
cout << " The number is not a Palindrome Number "<<endl;
}
getch ();
return 0;
}

ISNUMPALINDROME (number);
results = ISNUMPALINDROME;

This should be written as: results = ISNUMPALINDROME (number); If you search daniweb for Palindrome you should find plenty of examples.

This article has been dead for over six months. Start a new discussion instead.