Advertisement
ekostadinov

C# ExchangeTwoIntValues

Oct 1st, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. //Declare  two integer variables and assign them with 5 and 10 and after that exchange their values.
  2.  
  3.  
  4. using System;
  5.  
  6.     class ExchangeValues
  7.     {        
  8.  
  9.         static void Main()
  10.         {
  11.             int firstValue = 5;
  12.             int secondValue = 10;
  13.  
  14.             Console.WriteLine("If your numbers are {0} and {1}!", firstValue, secondValue);
  15.  
  16.             firstValue = firstValue + secondValue;
  17.             secondValue = firstValue - secondValue;
  18.             firstValue = firstValue - secondValue;
  19.  
  20.             Console.WriteLine("After the exchange the values are {0} and {1}!", firstValue, secondValue);
  21.         }
  22.        
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement