public static void main(string[] args)
output("Enter a 3-digit number whose digits are decreasing:" + "\n");
number = (int) inputValue();
a = (double) number / 100;
c = (double) number / 10 % 10;
reverse = b.toString() + c + a;
second = number - Convert.ToInt32(reverse);
a1 = (double) second / 100;
c1 = (double) second / 10 % 10;
again = b1.toString() + c1 + a1;
output("The original number is " + number + "\n");
output(number.toString() + " - " + reverse + " = " + (number - Convert.ToInt32(reverse)) + "\n");
output(number - Convert.ToInt32(reverse).toString() + " + " + again + " = " + (number - Convert.ToInt32(reverse) + Convert.ToInt32(again)) + "\n");
output("The magic number is " + (number - Convert.ToInt32(reverse) + Convert.ToInt32(again)) + "\n");
' .NET can only read single characters or entire lines from the console.
' The following functions are designed to help input specific data types.
private static double inputValue()
while (!double.TryParse(Console.ReadLine(), out result));
private static string inputText()
return Console.ReadLine()
private static output(string text)