C# Program to Print Reverse Of a Given Number
C# PROGRAM TO PRINT THE REVERSE OF A GIVEN NUMBER
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
using System; namespace ReverseNumber { class Program { static void Main(string[] args) { int num, rem, sum = 0, rev; Console.WriteLine("\n /** To Find Reverse Of a Number **/"); Console.Write("\n Enter a number: "); num=Convert.ToInt32(Console.ReadLine()); while (Convert.ToBoolean(num)) { rem = num % 10; //for getting remainder by dividing with 10 num = num / 10; //for getting quotient by dividing with 10 sum = sum * 10 + rem; } rev = sum; Console.WriteLine("\n The Reversed Number is: {0} \n\n", rev); Console.ReadLine(); } } } |
For C Program : C Program To Find The Reverse Of a Given Number