Advertisement
VyaraG

ExchangeVariableValues

Nov 28th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. //Declare two integer variables a and b and assign them with 5 and 10 and after that exchange their values by using some programming logic. Print the variable values before and after the exchange.
  2.  
  3.     class ExchangeVariableValues
  4.     {
  5.         static void Main()
  6.         {
  7.             int a = 5;
  8.             int b = 10;
  9.  
  10.             Console.WriteLine(a);
  11.             Console.WriteLine(b);
  12.  
  13.             int c = 5;
  14.  
  15.             a = b;
  16.             b = c;
  17.             Console.WriteLine(a);
  18.             Console.WriteLine(b);
  19.  
  20.         }
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement