Please assist me in wiriting the following program... People sometimes give thei
ID: 3542616 • Letter: P
Question
Please assist me in wiriting the following program...
People sometimes give their telephone number using one or more alphabetic characters. Write a program that takes a single letter and displays the corresponding number. Look at your telephone to determine which numbers correspond to which characters. If the user enters one of those letters, display a message indicating that the value does not match a number.Allow both uppercase and lowercase characters to be entered.Test your program using your own phone number.
Thank you for your time and assistance!
Explanation / Answer
#include<stdio.h>
voi main(){
int i = 0;
char phoneNo[10];
for(int j = 0;j<10;j++)
{
char digit;
scanf("%c "&digit);
switch(digit){
case r:
case R: phoneNo[j]= '1';break;
case t:
case T: phoneNo[j]= '2';break;
case y:
case Y: phoneNo[j]= '3';break;
case f:
case F: phoneNo[j]= '4';break;
case g:
case G: phoneNo[j]= '5';break;
case h:
case H: phoneNo[j]= '6';break;
case v:
case V: phoneNo[j]= '7';break;
case b:
case B: phoneNo[j]= '8';break;
case n:
case N: phoneNo[j]= '9';break;
case m:
case 0: phoneNo[j]= '0';break;
default: print(please enter valid no.);j--; break;
}
}
for(int j = 0 ;j<10;j++)
print("%c",phoneNo[j]);
}