Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //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
- class ExchangeValues
- {
- static void Main()
- {
- int firstValue = 5;
- Console.WriteLine("a = {0}", firstValue);
- int secondValue = 10;
- Console.WriteLine("b = {0}",secondValue);
- firstValue = firstValue + secondValue; // a = 15
- secondValue = firstValue - secondValue; // b = 5
- Console.WriteLine("b = {0}", secondValue);
- firstValue = firstValue - secondValue; // a = 10
- Console.WriteLine("a = {0}", firstValue);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement