Solution:
-
Declare two variables (n and lastDigit).
-
Read the user input from the console. (int.Parse(Console.ReadLine());).
-
Find the last digit of the number by the formula: int lastDigit = n % (10); (Use modular division - the operator % in C#).
-
Print the result on the console (Console.WriteLine(lastDigit));)
using System;
class LastDigit
{
static void Main()
{
Console.WriteLine("Please write your number:");
long n = long.Parse(Console.ReadLine());
long lastDigit = n % (10); //or int or double - whatever numeral data type suits you
Console.WriteLine("The last digit of your number {0} is: {1}", n, lastDigit);
}
}