Skip to main content

AD

The following program reads the letter from A to Z and prints it's corresponding telephone digit. This program uses a sentinal controlled while loop . To stop the program user is promoted for the sentinal which is # .

 The following program reads the letter from A to Z and prints it's corresponding telephone digit. This program uses a sentinal controlled while loop . To stop the program user is promoted for the sentinal which is # .


SOURCE  CODE :-

#include <iostream> 
using namespace std; 
int main() 
char letter ;
cout << "This is a program to convert uppercase Letter from A to Z into their corresponding telephone digit " << endl ;
cout << "To stop this program enter # " << endl ;
cout << "Enter an uppercase letter : " << endl ;
cin >> letter ;
while (letter != '#' )
{
cout << "The letter you entered is " << letter << " and the corresponding telephone digit is : " << endl ;
if (letter >= 'A' && letter <= 'Z' )
{
switch (letter)
{
case 'A' :
case 'B' :
case 'C' :
cout << "2" << endl ;
break ;
case 'D' :
case 'E' :
case 'F' :
cout << "3" << endl ;
break ;
case 'G' :
case 'H' :
case 'I' :
cout << "4" << endl ;
break ;
case 'J' :
case 'K' :
case 'L' :
cout << "5" << endl ;
break ;
case 'M' :
case 'N' :
case 'O' :
cout << "6" << endl ;
break ;
case 'P' :
case 'Q' :
case 'R' :
case 'S' :
cout << "7" << endl ;
break ;
case 'T' :
case 'U' :
case 'V' :
cout << "8" << endl ;
break ;
case 'W' :
case 'X' :
case 'Y' :
case 'Z' :
cout << "9" << endl ;
break ;
}
}
else
cout << "Invalid input "<< endl ;
cout << "Enter another uppercase letter to find it's corresponding telephone digit, To stop the program please enter '#' " << endl ;
cin >> letter ;
cout << endl ;
}
return 0 ;
}

Follow us for more posts like this ........

Comments

Popular posts from this blog

Different Species of Cheetahs Present in the World

  Different Species of C heetah Present in the World :- There is only one species of cheetah, which is called Acinonyx jubatus. Cheetahs are found in various parts of Africa, as well as in a small population in Iran. There are several subspecies of cheetah, including: Acinonyx J ubatus V enaticus : -   Acinonyx jubatus venaticus, also known as the Asiatic cheetah, is a subspecies of cheetah found in Central Asia and the Transcaucasus region. It is the only remaining population of cheetahs in Asia, and is critically endangered with fewer than 50 individuals remaining in the wild. The Asiatic cheetah is adapted to living in arid and semi-arid environments, and is found in grasslands, savannas, and steppes. It is slightly smaller in size compared to other subspecies of cheetah, and has a longer and thicker coat to help it survive in colder climates. The Asiatic cheetah is threatened by habitat loss, poaching, and conflict with humans. Conservation efforts are underway to ...

Best ways to use your free time. What to do in your free time?

20 best ways to use your free time. What to do in your free time? If you have a large block of free time, the best way to use it is to relax, have fun, unwind from a stressful day or spend time with a loved one. But if you only have a small chunk – say 5 or 10 minutes – there's no time to do any fun stuff. So what to do in your spare time? Put these small chunks of time to their most productive use. Everyone works differently, so the best use of your free time really depends on you, your work style, and what's on your to-do list. But it is useful to have such a list so that you can quickly find a way to put the little free time to work immediately, without any thought. Use the following list as a way to spark ideas for what you can do in a short amount of time. 1. Reading files Cut out magazine articles or print out good articles or news to read later and save them in a folder labeled "Reading File." Take it wherever you are, and whenever you have a bit of...

1st Year Chemistry Short Questions (Chapter 7)

 If you are in 1st year class And searching for important short questions for your exams preparation than read it out  Here is some short questions from chapter 7 of 1st year  INTRODUCTION   1. What is thermochemistry Why it has limited scope? 2. What is the difference b/w exothermic & endothermic reactions? 3. What are thermochemical equations. Give two examples  4. Why is it necessary to mention physical and chemical states of reactant & products in thermochemical equations? 5. Why heat evolve in exothermic reactions & heat absorb in endothermic reactions? SYSTEM, SURRONDING AND STATE FUNCTION 6. Define system, surrounding& boundary with examples of each 7. Define state & state function with two examples SPONTANEOUS & NON-SPONTANEOUS REACTIONS 8. Differentiate spontaneous & non-spontaneous reactions 9. Explain that burning of candle (Coal) is a spontaneous process. 10. Is it true that non-spontaneous process never happened in the univer...