Can someone help me out to find an error in a c# code?

  • Thread starter Thread starter a_paris_m
  • Start date Start date
A

a_paris_m

Guest
Next program asks for a number from keyboard and calculates its number of digits considering those which are bigger than MAX.

The code isthe following:

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

namespace ex3
{
class cex3
{
const int MAX = 7;

static void Main(string[] args)
{
int original, num, count = 0;

Console.WriteLine("Write down a number:");
num = Convert.ToInt32(Console.ReadLine());
original = num;

while (num / 10 != 0)
{
if (num % 10 > MAX)
count++;
num = num / 10;
}

Console.WriteLine("The number " + original + " has " + count + " digits bigger than " + MAX);
Console.ReadLine();
}
}
}

Continue reading...
 
Back
Top