C C++ program to check palindrome number

C C++ program to check palindrome number

Switch statement और multibranching statements के बारे में अधिक जानने के लिए देखें—Switch statements in C

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Unconditional branching statements के बारे में अधिक जानकारी के लिए देखें— Break, Continue and Goto in C

Flowchart to check palindrome number

Check whether given number is palindrome or not flowchart

C program to check palindrome number

#include<stdio.h>
int main()
{
    int num,rem,rev=0,org;
    printf("Enter a number: ");
    scanf("%d",&num);
    org=num;
    while(num!=0)
    {
        rem=num%10;
        rev=rev*10+rem;
        num=num/10;
    }
    if(rev==org)
    {
        printf("Palindrome");
    }
    else
    {
        printf("Not a palindrome");
    }
    return 0;
}

C++ program to check palindrome number

#include<iostream>
using namespace std;
int main()
{
    int num,rem,rev=0,org;
    cout<<"Enter a number: ";
    cin>>num;
    org=num;
    while(num!=0)
    {
        rem=num%10;
        rev=rev*10+rem;
        num=num/10;
    }
    if(rev==org)
    {
        cout<<"Palindrome";
    }
    else
    {
        cout<<"Not a palindrome";
    }
    return 0;
}

Output of C C++ program to check palindrome number

Enter a number: 5665
Palindrome
Enter a number: 6438
Not a palindrome 

Other looping based programs in C and C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. HCF and LCM of two numbers
  10. Generating Fibonacci series
  11. Checking prime number
  12. Generating series of prime numbers
  13. Sum of digits of given number
  14. Reverse of digits of given number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

Published by

admin

I am a computer teacher, programmer and web developer