C++ || Telephone Digit Program – How To Convert Letters To Numbers Using C++

Print Friendly, PDF & Email

The following is a program with functions which demonstrates how to implement a telephone digit program which converts the letters on a phone number keypad to digits.

The program allows to convert more than one letter at a time, include a hyphen, and allows both upper and lower case.

For example, the input text of “get loan”, the output would be:


438-5626


1. Telephone Digit Program

The example below demonstrates how to convert letters to numbers.

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

Once compiled, you should get this as your output
(Note: the code was compiled separate times to display different output)

====== RUN 1 ======

This is a program to convert letters to their corresponding telephone digits.

Enter your letters: get loan

The number converted: 438-5626

====== RUN 2 ======

This is a program to convert letters to their corresponding telephone digits.

Enter your letters: getloan

The number converted: 438-5626

====== RUN 3 ======

This is a program to convert letters to their corresponding telephone digits.

Enter your letters: get-loan

The number converted: 438-5626

====== RUN 4 ======

This is a program to convert letters to their corresponding telephone digits.

Enter your letters: GETLOAN

The number converted: 438-5626

====== RUN 5 ======

This is a program to convert letters to their corresponding telephone digits.

Enter your letters: G e T L O a N

The number converted: 438-5626

====== RUN 6 ======

This is a program to convert letters to their corresponding telephone digits.

Enter your letters: 6572782011

The number converted: 657-278-2011

Leave a Reply