Question: This is for C Programming: Complete the program by providing the additional if-else branches for decoding other letters in a phone number. Try incrementally writing

This is for C Programming:

Complete the program by providing the additional if-else branches for decoding other letters in a phone number. Try incrementally writing the program by adding one "else if" branch at a time, testing that each added branch works as intended.

#include

int main(void) { char phoneChar; // Current char in phone number string

printf("Enter phone number: ");

scanf("%c", &phoneChar); // Reads first char of user input printf("Numbers only: ");

while (phoneChar != ' ') {

if (((phoneChar >= '0') && (phoneChar <= '9')) || (phoneChar == '-')) { printf("%c", phoneChar); // Print element as is } else if ( ((phoneChar >= 'a') && (phoneChar <= 'c')) || ((phoneChar >= 'A') && (phoneChar <= 'C')) ) { printf("2"); } // FIXME: Add remaining else-if branches else { printf("?"); }

scanf("%c", &phoneChar); // Read next char of user input }

printf(" ");

return 0;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!