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

A PICNIC . Essay post for students. (Essay post)

  Hi . This is TNWRITES . In today's post we are going to discuss abour essay A PICNIC ... "Unless you are at a picnic, life is no picnic.” A picnic is a short trip for pleasure to a beautiful place. Picnics add spice  to our life. They provide much relief  from our routine life. They are a great stress buster  as they help reduce the stress and anxiety related to work and home. They refresh out tired nerves. Picnics give Students a temporary relief from their studies. After enjoying a picnic , they feel  fresh and take up their studies with renewed vigor. Every school  and college arranges picnics for its students. "People who cannot find  time for recreation are obliged sooner or later to find time for illness." Just the word ‘picnic’ brings a cheer and smile to the face of students, whether simply going to a park or a historical monument  or any other place. The atmosphere is one of excitement, fun and frolic . “Nothing's better than a pic...

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

WHY I Love PAKISTAN .. Essay post for students .(Essay post)

 Hi . This is TNWRITES . In today's post we are going to discuss abour essay  WHY I Love PAKISTAN  “Patriotism is a kind of religion ; it is the egg from which wars are hatched.”  Love for one‘s  motherland  is a natural feeling . I love Pakistan because it is my mother-land. I was born and brought up in this country. Man cannot  help loving the native place where he saw the light. I love Pakistan because its soil has gone into my bones and my being. My flesh-and blood are the product of this piece of earth. I eat its food, drink its water and breathe in its air, walk on its soil, live in a house made from its mud and hope to be buried in its soil after my death. So loving  Pakistan is, in fac , loving myself . “Love for one’s country is an article of faith.” Pakistan is dear to me for the sacrifices madé by our ancestors to win this homeland . They struggled hard to liberate it from the clutches of the English imperialists and prejudiced Hi...