To count number of digit in C# using while Loop



To count number of digit in C# using while Loop

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MYPROJECT.startup
{
    class Startupday1
    {
        static void Main()
        {

            Console.Write("enter number");
            int n = int.Parse(Console.ReadLine());
            int count = 0;
            while (n > 0)
            {
                n = n / 10;
                count++;
                
            }
           
            Console.Write("number of digits are {0}",count);
            Console.ReadKey();
        }
    }

}
                                    ANSWER




Comments

Popular posts from this blog

Input and output in C#

Printing Hello World in C#

Passing value without reference in C#