Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

socialist egalitarianism which resulted in wage levelling;

Answered: 1 week ago

Question

soyuznye (all-Union, controlling enterprises directly from Moscow);

Answered: 1 week ago