Q:

C++ program to Check whether a number is palindrome or not

belongs to collection: C++ Number Solved Programs

0

Write a C++ program to Check whether a number is palindrome or not using while loop. Here’s simple program to Check whether a number is palindrome or not using while loop in C++ Programming Language.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

A Palindrome number is a number that remains the same when its digits are reversed.

 
 

For example: we take 121 and reverse it, after reverse it is same as original.

Here is source code of the C++ program to Check whether a number is palindrome or not using while loop. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.


SOURCE CODE : :

/*  C++ program to Check whether a number is palindrome or not  */

#include<iostream>
using namespace std;

int main()
{
    int a,no,b,temp=0;

    cout<<"Enter any positive number :: ";
    cin>>no;

    b=no;

    while(no>0)
    {
        a=no%10;
        no=no/10;
        temp=temp*10+a;
    }

    if(temp==b)
    {
        cout<<"\nThe Number [ "<<b<<" ] is Palindrome.\n";
    }
    else
    {
        cout<<"\nThe Number [ "<<b<<" ] is Not Palindrome.\n";
    }

    return 0;
}

Output : : 


/*  C++ program to Check whether a number is palindrome or not  */

Enter any positive number :: 12321

The Number [ 12321 ] is Palindrome.

Process returned 0

Above is the source code for C++ program to Check whether a number is palindrome or not which is successfully compiled and run on Windows System.The Output of the program is shown above .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Number Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C++ Program to Calculate HCF of Two Numbers using ... >>
<< C++ program to Find Largest of three numbers using...