Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write program for palindrome

Answer Posted / vineet

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

#define FALSE 0
#define TRUE 1

int power(int num, int pow)
{
int finalNum = 1;
while(pow)
{
finalNum = finalNum*num;
pow--;
}
return finalNum;
}


bool IsPalindrome1(int n)
{
bool retVal = TRUE;
int indx=0, i=1, a=0;
int arr[10]={0,};

if(0 == (n%10))
return FALSE;

while(n)
{
a=(n%(power(10,i)))/power(10, (i-1));
n = n-(a*power(10,(i-1)));
arr[indx]=a;
indx++;
i++;
}
i--;
for(int j=0;j<=(i/2);j++)
{
if(arr[j] == arr[i-j-1])
retVal = retVal & TRUE;
else
retVal = retVal & FALSE;
}
return retVal;
}


void main()
{
int n=0;
bool b=FALSE;
cout<<" Enter a number to check whether it is a
palindrome or not:";
cin>>n;
b = IsPalindrome2(n);
if(TRUE == b)
cout<<"The number is palindrome"<<endl;
else
cout<<"The number is NOT a
palindrome"<<endl;
getche();
}

Is This Answer Correct ?    18 Yes 28 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.

1016


What is c++ 11 and c++ 14?

1009


Explain what are accessor methods?

1074


C is to C++ as 1 is to a) What the heck b) 2 c) 10

1019


How important is c++?

931


What is & in c++ function?

1016


What are the four partitions in which c++ compiler divides the ram?

1179


Why namespace is used in c++?

1022


What is the basic concept of c++?

966


How does the copy constructor differ from the assignment operator (=)?

1101


What is the difference between a "copy constructor" and an "assignment operator" in C++?

1030


What is protected inheritance?

1012


What can I safely assume about the initial values of variables which are not explicitly initialized?

1011


What is the need of a destructor?

1083


What can I use instead of namespace std?

1084