Check whether a number is a palindrome or not? - Amit Notes

Latest

Jun 1, 2021

Check whether a number is a palindrome or not?

 Write a program in C# Sharp to check whether a number is a palindrome or not.

Program

using System;  
public class AmitNotes 
{  
    public static void Main()
{
    int num,r,sum=0,t;
Console.Write("\n\n");
    Console.Write("Check whether a number is a palindrome or not:\n");
    Console.Write("------------------------------------------------");
    Console.Write("\n\n"); 

    Console.Write("Input a number: ");
    num = Convert.ToInt32(Console.ReadLine());

    for(t=num;num!=0;num=num/10){
         r=num % 10;
         sum=sum*10+r;
    }
    if(t==sum)
         Console.Write("{0} is a palindrome number.\n",t);
    else
         Console.Write("{0} is not a palindrome number.\n",t);
}  
}


Output:-


Check whether a number is a palindrome or not:
------------------------------------------------
Input a number: 8
8 is a palindrome number




-------------------------END--------------------------



1 comment:

  1. Thank you for explaining about the importance and benefits of the sports and we do have a sports magazine which gives complete information about the sports.
    Interview of sports person
    2021 Olympics India

    ReplyDelete

If you have any doubts, Please let me know