On this weblog, we are going to be taught Learn how to examine a quantity is Palindrome or not in C#. This Can be one of the vital common interview questions among the many interviewers. The essential method is to reverse the quantity after which examine it with the quantity added by the person.
Some Applications which is likely to be helpful are:
Let’s create this system in C#:
int Quantity, TmpNumber, Reverse; Console.WriteLine(“Enter //Get quantity from the person Quantity = int.Parse(Console.ReadLine()); //Maintain the quantity within the TmpNumber TmpNumber = Quantity; Reverse = 0; //Reverse the Quantity whereas (Quantity > 0) { int the rest = Quantity % 10; Reverse = (Reverse * Quantity = Quantity / 10; } //Evaluate the Reversed quantity with the quantity entered by the if (TmpNumber == Reverse) { Console.WriteLine(“‘{0}’ no. is an instance of Palindrome”, TmpNumber); } else { Console.WriteLine(“‘{0}’ no. isn’t an instance of Palindrome”, TmpNumber); } //Console.ReadLine() to carry the display after the execution of Console.ReadLine(); |
Output:
I hope this can provide help to in your interview preparation/examination.
Thanks