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
Post a Comment