Advertisement
Guest User

06 Increment Variable

a guest
Apr 7th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _06_Increment_Variable
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int count = 0;
  15.  
  16.             for (int i = 1; i <= n; i++)
  17.             {
  18.                 if (i % 256 == 0)
  19.                 {
  20.                     count++;
  21.                 }
  22.             }
  23.             if (n > 255)
  24.             {
  25.             Console.WriteLine(n - (count * 256));
  26.             Console.WriteLine("Overflowed {0} times", count);
  27.             }
  28.             else
  29.             {
  30.                 Console.WriteLine(n);
  31.             }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement