Advertisement
AnitaN

02.PrimitiveDataTypesVariables/10.ExchangeVariableValues

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