a point charge a lies at the center of an insulting solid spherical shell of inn
ID: 3601423 • Letter: A
Question
a point charge a lies at the center of an insulting solid spherical shell of inner radish r1 a point charge a lies at the center of an insulting solid spherical shell of inner radish r1 a point charge a lies at the center of an insulting solid spherical shell of inner radish r1 a point charge a lies at the center of an insulting solid spherical shell of inner radish r1 There are 9 words in the statement Problem 2 (15 points): Word to Phone number On the phone keypad, each number (except 0 and 1) corresponds to 3 or 4 alphabetic characters. In business, the owners may want their phone number to represent their business such as a barbershop may want their phone number to say HAIRCUT or a car dealer may want the phone number to say 601CARS. Write a C program to ABC DEF GHI UKL UNO PORS TUV WAYZ - Let a user enter a 7-character word. Your program must use void getword(char word]) function-more details next page. - Translate the 7-char word to a phone number and display it. - Be interactive- ask a user whether he/she wants to continue See Sample code execution next page void getword (char word[]) /I This function is to output an 8-element array called "word" that consists of /I only seven alphabets ('a -z and 'A Z) or digits (e-9) // The last elenent of the array is the null character //if a user enter more than 7 characters - ask a user to enter again //if a user enter any symbols such as &, ,, etc. - ask a user to enter again Sample code execution: Red entered by a user Enter a 7-character word: W1L Dcats Enter ONLY 7 characters Enter a 7-character word: wil symbol cannot be used as a pl Page 1 2 Type here to searchExplanation / Answer
Here is the code for you:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
void getword(char word[])
//This function is to output an 8-element array called word, that consists of
//only seven alphabets ('a' - 'z' and 'A' - 'Z') or digits ('0' - '9').
//If a user enter more than 7 characters - ask a user to enter again.
//If a user enter any symbols such as &, $, @ etc. - ask a user to enter again.
{
printf("Enter a 7-character word: ");
scanf("%s", word);
if(strlen(word) != 7)
{
printf("Enter ONLY 7 characters. ");
getword(word);
}
else
{
int alnum = 1;
for(int i = 0; i < 7; i++)
if(!isalnum(word[i]))
alnum = 0;
if(!alnum)
{
printf("Symbol cannot be used as a phone number. ");
getword(word);
}
else
printf("The phone word is: %s ", word);
}
}
int main()
{
char word[8];
getword(word);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.