A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a C# Sharp program to check if two given non-negative integers have the same last digit
Q:

Write a C# Sharp program to check if two given non-negative integers have the same last digit

0

Write a C# Sharp program to check if two given non-negative integers have the same last digit

Sample Output:

False
True
True
False

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
namespace exercises
{
   class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(test(123, 456));
            Console.WriteLine(test(12, 512));
            Console.WriteLine(test(7, 87));
            Console.WriteLine(test(12, 45));
            
            Console.ReadLine();
        }

   public static bool test(int x, int y)
        {
            return Math.Abs(x % 10) == Math.Abs(y % 10);
        }
  }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now