GeekInterview.com
Series: Subject: Topic:
Question: 344 of 827

write a program to check if the number is palindrome or not using recursive function.

Asked by: Interview Candidate | Asked on: Mar 29th, 2007
Showing Answers 1 - 2 of 2 Answers
baseersd

Answered On : Jul 24th, 2007

View all answers by baseersd

Here is the code for palindrome with recursive mechanism#include<stdio.h>int rev=0; //Global Variableint REV(int num){if(num>0){ rev=(rev*10)+ (num %10); REV(num / 10); //calling the Function recursively.         }return rev;        }int main(){int num;printf("nEnter a number ");scanf("%d",&num);if(num==REV(num))printf("nNumber is a Palindrome");elseprintf("nNot a palindrome");getch();    }

Yes  2 Users have rated as useful.
  
Login to rate this answer.

Main{ int sum = 0,n,n1,r;  printf(" enter the number to be tested for palimdromen" );  scan("%d",&n);   n1=n;   while(r!=0)   {r=n%10;     n=n/10;      sum = sum*10+r;   }  if(sum==n1){  printf(" the number is palimdromen ");  }  else      { printf(" the number is not palimdromen");      }  }/* the program is written for LINUX users */

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.