Monday, 13 July 2015

Write C Program to Check Wheather Input Number is Palindram or not

1:  #include <stdio.h>  
2:  int main()  
3:  {  
4:    int n, reverse = 0, temp;  
5:    printf("Enter a number to check if it is a palindrome or not\n");  
6:    scanf("%d",&n);  
7:    temp = n;  
8:    while( temp != 0 )  
9:    {  
10:     reverse = reverse * 10;  
11:     reverse = reverse + temp%10;  
12:     temp = temp/10;  
13:    }  
14:    if ( n == reverse )  
15:     printf("%d is a palindrome number.\n", n);  
16:    else  
17:     printf("%d is not a palindrome number.\n", n);  
18:    return 0;  
19:  }  

No comments:

Post a Comment