gospod1978

Methods-Ex\Add and Subtract

Oct 13th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace methods_exerci
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int number = 0;
  10.             Console.WriteLine(Sum(number));
  11.            
  12.         }
  13.  
  14.         static int Sum(int number)
  15.         {
  16.             int sum = 0;
  17.             for (int i = 0; i < 3; i++)
  18.             {
  19.               number = int.Parse(Console.ReadLine());
  20.                 if(i < 2)
  21.                 {
  22.                     sum += number;
  23.                 }
  24.                 else
  25.                 {
  26.                     sum -= number;
  27.                 }
  28.  
  29.             }
  30.  
  31.             return sum;
  32.         }
  33.     }
  34. }
Add Comment
Please, Sign In to add comment