Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

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:

Flowchart: C# Sharp Exercises - Check whether a two digit given number is greater than its swap value.

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.