0

I'm getting the last number of a number , but have to convert last number to a string, as 14 ="Four" , 12 ="two"

using System;

namespace Program
{

    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

            string word = "";

        }
    }
}

Except : 10 = "zero" , 14 = "Four"

macropod
  • 12,757
  • 2
  • 9
  • 21

1 Answers1

0

Simply use an array of alphabetic numbers and call the appropriate index.

const string[] alphabaticNumbers=new string[]{"Zero","One" ,....};
string word= alphabaticNumbers[lastDigit];
Mahdi Farhani
  • 964
  • 1
  • 9
  • 22