Sample Qustion 3

Write a C++ program to find the reverse of a given number and check whether it is a palindrome or not.

#include<iostream>
using namespace std;
int main()
{
    int n, num, digit, rev = 0;
    cout << "Enter number" << endl;
    cin >> num;
    n = num;

    do
    {
            digit = num %10;
            rev = (rev * 10) + digit;
            num = num / 10;
    }
    while( num !=0);

    cout << rev << endl;

    if(n == rev)
    {
        cout <<"is palindrome" << endl;
    }
    else
    {
        cout <<"not palindrome" << endl;
    }
     return 0;
}


download file cpp file

do you have any qustion please comment  


click the advertisement to help for me ....



Comments