In this C# tutorial we are "printing reverse of any number entered by the user" . Here we are taking three variables "num" for number ,"rem" for remainder and "rev" for reverse respectively. Now, lets get started!!
using System; class rev { public static void Main(String []args) { int num,rem=0,rev=0; Console.WriteLine("Please enter any three or four digit number : "); num=Convert.ToInt32(Console.ReadLine()); while(num!=0) { rem=num%10; num=num/10; rev=rev*10+rem; } Console.WriteLine(rev); } }
0 comments:
Post a Comment