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 a recursive program in'c'to find whether a given five
digit number is a palindrome or not

Answer Posted / swapnil chhajer

//////////////////////////////////////////////////
//////// PROGRAM TO CHECK PALINDROME //////////
///// Developed By : Swapnil Chhajer ////////
//////////////////////////////////////////////////



#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int palindrome(int n)
{
char temp[10];
itoa(n,temp,10);
int len=strlen(temp);
int ret;

if(len == 1)
{
return 1;
}
else if(len == 2)
{
return(temp[0] == temp[1]);
}
else
{
if(temp[0] == temp[len-1])
{
temp[len-1]='\0';
ret = palindrome(atoi(temp+1));
}
else
{
return 0;
}
}
return ret;
}


int main()
{
int n;
printf("Enter the number : ");
scanf("%d",&n);
if(palindrome(n) == 1)
printf("\n\n:: PALINDROME ::");
else
printf("\n\n:: NOT A PALINDROME ::");
getchar();
return 0;
}

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many bytes are occupied by near, far and huge pointers (dos)?

1165


how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.

1690


How a string is stored in c?

1077


What is the full form of getch?

1286


Why #include is used in c language?

1059


Why doesnt long int work?

1052


What are variables c?

1058


What is wrong with this statement? Myname = 'robin';

1332


Explain the difference between ++u and u++?

1143


List some basic data types in c?

1034


Who invented bcpl language?

1202


Explain how are 16- and 32-bit numbers stored?

1275


Why is a semicolon (;) put at the end of every program statement?

1080


What is the difference between #include and #include 'file' ?

1070


A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles

1184