Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class ExchangeTwoIntNumsIfFirstIsBigger
- {
- static void Main()
- {
- //Telerik Academy
- //Write an if statement that examines two integer variables and exchanges their values if the first one is greater than the second one.
- Console.Write("Please enter the first integer number:");
- int firstNum = int.Parse(Console.ReadLine());
- Console.Write("Please enter the second integer number:");
- int secondNum = int.Parse(Console.ReadLine());
- if (firstNum == secondNum)
- {
- Console.WriteLine("The first number is equal to the second one! {0} = {1}", firstNum, secondNum);
- }
- else if (firstNum < secondNum)
- {
- Console.WriteLine("The first number is smaller than the second one! {0} < {1}", firstNum, secondNum);
- }
- else if (firstNum > secondNum)
- {
- Console.WriteLine("The first number is bigger than the second one! {0} > {1}", firstNum, secondNum);
- firstNum += secondNum;
- secondNum = firstNum - secondNum;
- firstNum -= secondNum;
- Console.WriteLine("The first number is now equal to {0} and the second number is equal to {1}!", firstNum, secondNum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement