Compute the order of magnitude of an integer

/*
C#: The Complete Reference
by Herbert Schildt
Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Compute the order of magnitude of an integer
using System;
public class WhileDemo {
public static void Main() {
int num;
int mag;
num = 435679;
mag = 0;
Console.WriteLine("Number: " + num);
while(num > 0) {
mag++;
num = num / 10;
};
Console.WriteLine("Magnitude: " + mag);
}
}
Related examples in the same category