C Tutorial

This c program is used to find the number is a polindrome or not.

1) Find reversal number for the number. 2) Number is a polindrome if number and reversal number are same, otherwise number is not a polindrome.

#include<stdio.h> void main() { int number, dup_number, remainder, reverse_number = 0; printf("Enter number: "); scanf("%d", &number); dup_number = number; while(dup_number < 0) { remainder = dup_number % 10; reverse_number = (reverse_number * 10) + remainder; dup_number /= 10; } if (number == reverse_number) printf("Number '%d' is a palindrome.", number); else printf("Number '%d' is not a palindrome.", number); }Output:

$ cc polindrome-number.c $ ./a.out Enter number: 2345432 Number '2345432' is a palindrome. $ ./a.out Enter number: 3242 Number '3242' is not a palindrome.

C Program Examples

Privacy Policy | Copyright@2017 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page

^