A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

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

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

0

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

Sample Output:

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;  
public class Exercise38 
{  
    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);
	}	 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now