C#: Check whether a two digit given number is greater than its swap value
Check Swapped Two-Digit Number
Write a C# Sharp program to swap a two-digit number and check whether the given number is greater than its swap value.
Sample Solution:
C# Sharp Code:
using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
// Prompting the user to input an integer value
Console.WriteLine("Input an integer value:");
// Reading the input from the user and converting it to an integer
int n = Convert.ToInt32(Console.ReadLine());
// Checking if the given value is greater than or equal to its swap value
Console.WriteLine("Check whether the said value is greater than its swap value: " + test(n));
}
// Method to check if a value is greater than its swap value
public static bool test(int n)
{
// Calculating the swap value and comparing it with the original value
return (int)(n / 10) >= n % 10;
}
}
}
Sample Output:
Input an integer value: Check whether the said value is greater than its swap value: True
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C# program to find the difference between a two-digit number and its reversed version.
- Write a C# program to determine if a two-digit number becomes a multiple of 11 when its digits are swapped.
- Write a C# program to count how many two-digit numbers are greater than their reversed counterpart.
- Write a C# program to swap digits of a two-digit number and check if both numbers are prime.
Go to:
PREV : Convert Array Elements to Strings.
NEXT : Remove Non-Letter Characters.
C# Sharp Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.