C# Sharp Exercises: Check whether a two digit given number is greater than its swap value
C# Sharp Basic: Exercise-81 with Solution
Write a C# Sharp program to swap a two digit given number and check whether the given number is greater than its swap value.
Sample Solution:
C# Sharp Code:
using System;
using System.Linq;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Input an integer value:");
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Check whether the said value is greater than its swap value: " + test(n));
}
public static bool test(int n)
{
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:
C# Sharp Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a C# Sharp program to convert all the values of a given array of mixed values to string values.
Next: Write a C# Sharp program to remove all characters which are non-letters from a given string.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework