Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 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 Praktika6
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.            
  14.             Solution_08();
  15.             Console.ReadKey();
  16.         }
  17.  
  18.         static void Solution_08()
  19.         {
  20.             Console.WriteLine("Solution_08: Integer increment from A to B");
  21.             Console.WriteLine("Enter number A");
  22.             int a = int.Parse(Console.ReadLine());
  23.             Console.WriteLine("Enter number B");
  24.             int b = int.Parse(Console.ReadLine());
  25.             Console.WriteLine("Sum from A to B = " + (Solution_08(a, b)));
  26.             Console.WriteLine();
  27.         }
  28.  
  29.         private static int Solution_08(int a, int b)
  30.         {
  31.             int sum = 0;
  32.             for (int i = a; i <= b; i++)
  33.             {
  34.                 sum += i;
  35.             }
  36.             return sum;
  37.         }
  38.  
  39.        
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement