ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
write a recursive program in'c'to find whether a given five 
digit number is a palindrome or not
 Question Submitted By :: Cigi
I also faced this Question!!     Rank Answer Posted By  
 
  Re: write a recursive program in'c'to find whether a given five digit number is a palindrome or not
Answer
# 1
//////////////////////////////////////////////////
////////  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 ?    2 Yes 0 No
Swapnil Chhajer
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
How many types of linked lists what are they? How many types of data structures? BSNL5
write a program to swap bits in a character and return the value prototype of function char fun (char a, charb flag c) where fun returns a char, char a is a the value char b is the bit to be changed and flag c is the bit value for eg: x=fun(45,7,0) since 45 is 0010 0101 and ow x should contain the value 65 (0110 0101) Bosch1
main() { char *p; p="Hello"; printf("%c\n",*&*p); } ME2
Look at the Code: main() { int a[]={1,2,3},i; for(i=0;i<3;i++) { printf("%d",*a); a++; } } Which Statement is/are True w.r.t the above code? I.Executes Successfully & Prints the contents of the array II.Gives the Error:Lvalue Required III.The address of the array should not be changed IV.None of the Above. A)Only I B)Only II C)II & III D)IV Accenture3
i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k); HCL6
5. distance conversion: Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer  1
The C language terminator is a.semicolon b.colon c.period d.exclamation mark TCS3
which of the following statements is incorrect a.typedef struct new{ int n1; char n2; } DATA; b.typedef struct { int n3; char *n4; }ICE; c.typedef union { int n5; float n6; } UDT; d.#typedef union { int n7; float n8; } TUDAT; TCS5
who is the founder of c HP9
Evaluate the following: int fn(int v) { if(v==1 || v==0) return 1; if(v%2==0) return fn(v/2)+2; else return fn(v-1)+3; } for fn(7); 1) 10 2) 11 3) 1  6
Why the use of alloca() is discouraged? Oracle2
main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } what is the output? Ramco4
main is a predefined or user define function if user defined why? if predefined whay? TCS2
palindrome for strings and numbers----Can anybody do the prog? TCS6
There is a 100-story building and you are given two eggs. The eggs (and the building) have an interesting property that if you throw the egg from a floor number less than X, it will not break. And it will always brake if the floor number is equal or greater than X. Assuming that you can reuse the eggs which didn't broke; you got to find X in a minimal number of throws. Give an algorithm to find X in minimal number of throws.  2
what is the use of pointers  5
swap two integer variables without using a third temporary variable?  2
pgm to reverse string using arrays i.e god is love becomes love is god) (assumption:only space is used for seperation of words) no addtional memory used.i.e no temporary arrays can used. Persistent4
what is out put of the following code? #include class Base { Base() { cout<<"constructor base"; } ~Base() { cout<<"destructor base"; } } class Derived:public Base { Derived() { cout<<"constructor derived"; } ~Derived() { cout<<"destructor derived"; } } void main() { Base *var=new Derived(); delete var; } Honeywell2
difference between function & structure Verizon5
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com