4. Program to determine palindrome number
#include<stdio.h>#include<conio.h> // Linux user - Remove this int main() { // variable for a=number, n=to copy number, d=digit, rev=reverse of number int a,n,d=0,rev=0; // Inputting number printf("Enter any number to determine whether it is Palindrome or not:"); scanf("%d",&a); // copying number in n n=a; // Determining whether number is palindrome or not while(n!=0) { d=n%10; rev=rev*10+d; n=n/10; } // Displaying Whether number is palindrome or not if(a==rev) printf("Palindrome number"); else printf("Not a Palindrome Number"); getch(); // Linux user - Remove this return 0; }
No comments:
Post a Comment