Hi
i don't understand how the last line (in bold) can be executed. The method is called just before that line, so in my eyes, this line will never be executed, because (suppose the entered value = 12) when the method will start for the second time with value n/10, it will start from above and be stopped by the IF statement, no? But nevertheless it is executed. Thanks to explain me the logic order. When does that line be reached?
using System; public class x4 { static void Main() { Console.Write(" Input any number : "); int num = Convert.ToInt32(Console.ReadLine()); Console.Write(" The digits in the number {0} are : ",num); separateDigits(num); Console.Write("\n\n"); }
static void separateDigits(int n) { if (n < 10) { Console.Write("{0} ", n); return; } separateDigits(n / 10); Console.Write(" {0} ", n % 10); } }