Write a C program
to check the given number is a palindrome or not. or Write a
program to check the given number is a palindrome or not in C.
Program in C
Code:
/*Write a C program to check
the given number is a palindrome or not. or Write a program
to check the given number is a palindrome or not Using C*/
#include<stdio.h>
int main()
{
int num;
printf("Enter a number:");
scanf("%d",&num);
int num1=num;
int num2=0;
while(num!=0)
{
int rem=num%10;
num/=10;
num2=num2*10+rem;
}
if(num1==num2)
printf("It is Palindrome");
else
printf("It is not Palindrome");
}
Input/Output:
Enter a number:7667
It is Palindrome
Write a C++ program
to check the given number is a palindrome or not. or Write a
program to check the given number is a palindrome or not in C++.
Program in C++
Code:
/*Write a C++
program to check the given number is a palindrome or not. or Write
a program to check the given number is a palindrome or not using C++*/
#include<iostream>
using namespace std;
int main()
{
int num;
cout<<"Enter a number:";
cin>>num;
int num1=num;
int num2=0;
while(num!=0)
{
int rem=num%10;
num/=10;
num2=num2*10+rem;
}
if(num1==num2)
cout<<"It is Palindrome";
else
cout<<"It is not Palindrome";
}
Input/Output:
Enter a number:5432
It is not Palindrome
Write a JAVA
program to check the given number is a palindrome or not. or Write
a program to check the given number is a palindrome or not in Java.
Program in Java
Code:
/*Write a JAVA
program to check the given number is a palindrome or not. or Write
a program to check the given number is a palindrome or not using
Java*/
import java.util.Scanner;
public class NumberPalindromeCheck {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
int num;
System.out.println("Enter a number:");
num=cs.nextInt();
int num1=num;
int num2=0;
while(num!=0)
{
int rem=num%10;
num/=10;
num2=num2*10+rem;
}
if(num1==num2)
System.out.println("It is Palindrome");
else
System.out.println("It is not Palindrome");
cs.close();
}
}
Input/Output:
Enter a number:
956123
It is not Palindrome
Write a PYTHON to check
the given number is a palindrome or not. or Write a program to check
the given number is a palindrome or not in Python.
Program in Python
'''Write
a Python program to check the given number is a palindrome or not. or
Write a program to check the
given number is a palindrome or not
using Python '''
num=int(input("Enter a number:"))
num1=num
num2=0
while(num!=0):
rem=num%10
num=int(num/10)
num2=num2*10+rem
if(num1==num2):
print("It is Palindrome")
else:
print("It is not Palindrome")
Input/Output:
Enter a number:1221
It is Palindrome
0 Comments
Please do not Enter any spam link in the comment box