To provide context, I'm very new to C#, and am currently working my way through Wiley's Software Development Fundamentals. The question is the following:
You are developing a library of utility functions for your application. You need to write a method that takes an integer and counts the number of significant digits in it. You need to create a recursive program to solve the problem. How would you write such a program?.
I think I have created a solution to this question, however I'm unsure if this is correct as I don't know how to return a value stating "this is how many significant digits".
class Program
{
public static void Main(string[] args)
{
dig(55535);
}
public static int dig(int x)
{
if (x < 10)
{
return 1;
}
else
{
return 1 + dig(x / 10);
}
}
}