VelizarAvramov

07. Exchange Variable Values

Nov 15th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3.  
  4. namespace Demo
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int a = 5;
  11.             int b = 10;
  12.  
  13.             Console.WriteLine("Before:");
  14.             Console.WriteLine($"a = {a}");
  15.             Console.WriteLine($"b = {b}");
  16.  
  17.             int temp = a;
  18.             a = b;
  19.             b = temp;
  20.  
  21.             Console.WriteLine("After:");
  22.             Console.WriteLine($"a = {a}");
  23.             Console.WriteLine($"b = {b}");
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment