C C++ program to check palindrome number

 

Flowchart

Check whether given number is palindrome or not flowchart

 

Coding in C

#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;
}

 

Coding in C++

#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

Check whether given number is palindrome or not output

 

Published by

admin

I am a computer teacher, programmer and web developer