skipter icon

C# Increment Variable

skipter | PRO | 06/13/17 10:12:04 PM UTC | 0 ⭐ | 360 👁️ | Never ⏰ | []
C# |

520 B

|

None

|

0 👍

/

0 👎

using System;
using System.Globalization;
class PriceChangeAlert
{
    static void Main()
    {
        int num = int.Parse(Console.ReadLine());
        int counter = 0;
 
        if (num >= 256)
        {
            while (num >= 256)
            {
                num -= 256;
                counter++;
            }
            Console.WriteLine(num);
            Console.WriteLine($"Overflowed {counter} times");
        }
        else
        {
            Console.WriteLine(num);
        }
    }
}

Comments