Advertisement
skipter

C# Increment Variable

Jun 13th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. class PriceChangeAlert
  4. {
  5.     static void Main()
  6.     {
  7.         int num = int.Parse(Console.ReadLine());
  8.         int counter = 0;
  9.  
  10.         if (num >= 256)
  11.         {
  12.             while (num >= 256)
  13.             {
  14.                 num -= 256;
  15.                 counter++;
  16.             }
  17.             Console.WriteLine(num);
  18.             Console.WriteLine($"Overflowed {counter} times");
  19.         }
  20.         else
  21.         {
  22.             Console.WriteLine(num);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement