Friday, 1 December 2017

C# Program to Find Magnitude of Integer


Code:

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();
    }
}

Output:

Enter the Number : 3145678
Number : 3145678
Magnitude : 7


More C# Programs:




















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...