﻿ C Sharp - Test 2 given integers, each in the range 10..99

# C#: Check two given integers, each in the range 10..99

## C# Sharp Basic Algorithm: Exercise-53 with Solution

Write a C# Sharp program to check two given integers, each in the range 10..99. Return true if a digit appears in both numbers, such as the 3 in 13 and 33

Visual Presentation:

Sample Solution:-

C# Sharp Code:

``````using System; // Import the System namespace which contains fundamental types and base classes
using System.Linq; // Import the LINQ namespace for LINQ functionality

namespace exercises // Define a namespace called 'exercises'
{
class Program // Define a class named 'Program'
{
static void Main(string[] args) // The entry point of the program
{
// Output the result of test function with different integer arguments
Console.WriteLine(test(11, 21)); // Test with integers 11 and 21
Console.WriteLine(test(11, 20)); // Test with integers 11 and 20
Console.WriteLine(test(10, 10)); // Test with integers 10 and 10
Console.ReadLine(); // Wait for user input before closing the console window
}

// Function definition of test function that takes two integers 'x' and 'y' and returns a boolean
public static bool test(int x, int y)
{
// Check if any of the digits in 'x' or 'y' are equal (sharing the same digit place)
return x / 10 == y / 10 || x / 10 == y % 10 || x % 10 == y / 10 || x % 10 == y % 10;
}
}
}
```
```

Sample Output:

```True
False
True```

Flowchart:

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿