Program of palindrome number in c++





Program of palindrome number in c++

#include<iostream>
int main(){
    int num,r,sum,temp;
    int min,max;

    cout << "Enter the minimum range: ";
    cin >> min;

    cout << "Enter the maximum range: ";
    cin >>  max;

    cout << "Palindrome numbers in given range are: ";
    for(num=min;num<=max;num++){
         temp=num;
         sum=0;

         while(temp){
             r=temp%10;
             temp=temp/10;
             sum=sum*10+r;
         }
         if(num==sum)
            cout << num << " ";
    }
    return 0;
}


Check the given number is palindrome number or not by c++  program

#include<iostream>
int main(){
    int num,r,sum=0,temp;

    cout << "Enter a number: ";
    cin >> num;

    for(temp=num;num!=0;num=num/10){
         r=num%10;
         sum=sum*10+r;
    }
    if(temp==sum)
         cout << temp << " is a palindrome";
    else
         cout << " is not a palindrome";

    return 0;
}





Post a Comment