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...

Different Species of Owls Present in the World

  DIFFERENT SPECIES OF OWLS ALONG WITH THEIR PHOTOS :- Owls are one of the most iconic and fascinating groups of birds. With their large, forward-facing eyes, sharp talons, and silent flight, they have long captured the imaginations of people all over the world. There are more than 200 different species of owls, each with its own unique characteristics and behaviors. In this blog post, we will take a closer look at some of the most interesting and diverse species of owls. Barn Owl :- The Barn owl (Tyto alba) is a medium-sized owl that is found on every continent except Antarctica. These owls are known for their distinctive appearance, with a heart-shaped face and long, thin legs, and their distinctive, soft hooting call. Barn owls are nocturnal predators that feed primarily on small mammals, such as mice and rats. They have excellent hearing, which helps them locate their prey even in complete darkness, and they are important predators in many ecosystems. Barn owls are fou...