EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+
 

Write a program to find whether the given number is a palindrome or not.

Source Code

#include<stdio.h>
#include<conio.h>
int main (int argc, char *argv[])
{
  clrscr();
  int n,num,i,c=0,f=0;
  int ar[100];
  for(i=0;i<100;i++)
  {
10      ar[i]=0;
11    }
12    printf("\n Enter the number: ");
13    scanf("%d",&n);
14    num=n;
15    while(num>0)
16    {
17         ar[c]=num%10;
18         c++;
19         num/=10;
20    }
21    for(i=0;i<((c-1)/2);i++)
22    {
23      if(ar[i]!=ar[c-i-1])
24      {
25        f=1;
26        break;
27      }
28    }
29    printf("\n The number %d is",n);
30    if(f==1)
31        printf(" not a palindrome");
32    else
33        printf(" a palindrome");
34    getch();
35  }

Find More from our code collection
Armstrong number, binary number to a decimal number, bubble sort, decimal number to binary number, factorial of the given number factors, fibonacci numbers, HCF and LCM, matrix, mergesort, salary of the employee. palindrome, quadratic equation, star patterns, series etc. and much more...
#Return to Example Source Code