Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //Write an if-statement that takes two integer variables a and b and exchanges their values
- //if the first one is greater than the second one. As a result print the values a and b,
- //separated by a space.
- class ExchangeValueIfGreater
- {
- static void Main()
- {
- Console.Write("FirstValue = ");
- double firstValue = double.Parse(Console.ReadLine());
- Console.Write("SecondValue = ");
- double secondValue = double.Parse(Console.ReadLine());
- double thirdValue = 0;
- if (firstValue > secondValue)
- {
- thirdValue = firstValue;
- firstValue = secondValue;
- secondValue = thirdValue;
- }
- Console.WriteLine("{0} {1}", firstValue, secondValue);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement