Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class EchangeTwoIntegers
- {
- static void Main(string[] args)
- {
- int a, b; //digits to be entered
- bool successParse;
- do
- {
- Console.Write("Enter digit: ");
- successParse = int.TryParse(Console.ReadLine(), out a);
- } while (!successParse);
- do
- {
- Console.Write("Enter digit: ");
- successParse = int.TryParse(Console.ReadLine(), out b);
- } while (!successParse);
- Console.WriteLine("You entered {0} AND {1} ", a,b);
- if (a>b)
- {
- a = a + b;
- b = a - b;
- a = a - b;
- Console.WriteLine("The values will be exchanged");
- Console.WriteLine("Exchanged values are {0} AND {1}", a, b);
- }
- else
- {
- Console.WriteLine("The value won't be exchanged");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement