Advertisement
mess0011

u3_4

Oct 16th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 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 ConsoleApplication20
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Pls import nr1: ");
  14.             int nr1 = Convert.ToInt32(Console.ReadLine());
  15.  
  16.             Console.WriteLine("Pls import nr2: ");
  17.             int nr2 = Convert.ToInt32(Console.ReadLine());
  18.  
  19.             int min = Math.Min(nr1, nr2);
  20.             int max = Math.Max(nr1, nr2);
  21.             int sum = 0;
  22.  
  23.             for(int i = min; i < max+1; i++)
  24.             {
  25.                 sum += i;
  26.             }
  27.             Console.WriteLine("Total sum is {0}", sum);
  28.             Console.ReadLine();
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement