Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

appears most frequently in the string 6.Alphabetic Telephose Number Translator M

ID: 3743589 • Letter: A

Question

appears most frequently in the string 6.Alphabetic Telephose Number Translator Many conpanies use telephone numbers like 555-GET-FOOD so the nunber is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion: A, B, and 2 D, E, and F 3 G, H, andI" J, K, and L 5 M, N, and 0 -6 P, 0, R, and S 7 , u, and V-8 , X, Y, and Z = 9 Desiga a progran that asks the user to enter a 10-character telephone number in the format xxx-xxX-Xxxx. The progran should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-F00D the progran should display 555-438-3663. C

Explanation / Answer

#include <stdio.h>

#include <string.h>

char Digit(char ptr)

{

if(strchr("ABCabc", ptr)) return('2');

else if(strchr("DEFdef", ptr)) return('3');

else if(strchr("GHIghi", ptr)) return('4');

else if(strchr("JKLjkl", ptr)) return('5');

else if(strchr("MNOmno", ptr)) return('6');

else if(strchr("PQRSpqrs", ptr)) return('7');

else if(strchr("TUVtuv", ptr)) return('8');

else if(strchr("WXYZwxyz", ptr)) return('9');

return(ptr);

}

int main(void)

{

const char number[10], *ptr;

printf("Enter the 10 digit no");

scanf("%s",&number);

puts(number);

for(ptr = number; *ptr; ++ptr)

{

putchar(Digit(*ptr));

}

return(0);

}