Number palindrome program

Number palindrome in c

#include<stdio.h>
#include<conio.h>
void CheckPalindrome(int number);
void main()
{
int input;
printf("Enter your number \n");
scanf("%d",&input);
CheckPalindrome(input);
getch();
}
void CheckPalindrome(int number)
{
    int reverse = 0, r = 0, original = number ;
    while (number != 0)
    {
        r = number % 10;
        reverse = reverse * 10 + r;
        number /= 10;
    }
    if (reverse == original)
        printf("Yes, it is a palindrome number");
    else
        printf("No, it is not a palindrome number");
}

Output

Enter your number
121
Yes, it is a palindrome number

Number palindrome in c++

#include<iostream>
#include<conio.h>
using namespace std;
class Example
{
public: void CheckPalindrome(int number)
{
    int reverse = 0, r = 0, original = number ;
    while (number != 0)
    {
        r = number % 10;
        reverse = reverse * 10 + r;
        number /= 10;
    }
    if (reverse == original)
        cout<<"Yes, it is a palindrome number";
    else
        cout<<"No, it is not a palindrome number";
}
};
void main()
{
int input;
cout<<"Enter your number \n";
cin>>input;
Example ex;
ex.CheckPalindrome(input);
getch();
}

Output

Enter your number
1001
Yes, it is a palindrome number

Number palindrome in c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PallindromeNumberExample
{
class Program
{
public void CheckPalindrome(int number)
{
    int reverse = 0, r = 0, original = number ;
    while (number != 0)
    {
        r = number % 10;
        reverse = reverse * 10 + r;
        number /= 10;
    }
    if (reverse == original)
        Console.Write("Yes, it is a palindrome number");
    else
        Console.Write("No, it is not a palindrome number");
}
static void Main(string[] args)
{
    int input;
    Console.WriteLine("Enter your number");
    input = Convert.ToInt32(Console.ReadLine());
    Program p1 = new Program();
    p1.CheckPalindrome(input);
    Console.ReadLine();
}
}
}

Output

Enter your number
656
Yes, it is a palindrome number

Number palindrome in java

import java.util.*;
class AB
{
	public void CheckPalindrome(int number)
	{
	    int reverse = 0, r = 0, original = number ;
	    while (number != 0)
	    {
	        r = number % 10;
	        reverse = reverse * 10 + r;
	        number /= 10;
	    }
	    if (reverse == original)
	        System.out.println("Yes, it is a palindrome number");
	    else
	    	System.out.println("No, it is not a palindrome number");
	}
	
}
class examples
{
public static void main(String[] args)
	{
     int input;
     Scanner obj= new Scanner(System.in);
     System.out.println("Enter your number");
     input=obj.nextInt();
     
     AB ab=new AB();
     ab.CheckPalindrome(input);
	}
}

Output

Enter your number
535
Yes, it is a palindrome number

Write a comment


Name Email Message