programming-examples/c-sharp/Basic/C# Program to Find Magnitude of Integer.cs

26 lines
561 B
C#
Raw Normal View History

2019-11-18 14:44:36 +01:00
/*
* C# Program to Find Magnitude of Integer
*/
using System;
public class Program
{
public static void Main()
{
int num, mag=0;
Console.WriteLine("Enter the Number : ");
num = int.Parse(Console.ReadLine());
Console.WriteLine("Number: " + num);
while (num > 0)
{
mag++;
num = num / 10;
};
Console.WriteLine("Magnitude: " + mag);
Console.Read();
}
}
/*
Enter the Number : 3145678
Number : 3145678
Magnitude : 7