i'm trouble getting my program to print this output and repeat until asked to quit the program
Enter a telephone number using letterss (EXIT to quit):
GET LOAN
The corresponding telephone number is:
438-5626
Here's my code:
#include <stdio.h>
#include <string.h>
char getNumber(char aC) {
char c = ' ';
switch (aC) {
case 'A':
case 'B':
case 'C':
c = '2';
break;
case 'D':
case 'E':
case 'F':
c = '3';
break;
case 'G':
case 'H':
case 'I':
c = '4';
break;
case 'J':
case 'K':
case 'L':
c = '5';
break;
case 'M':
case 'N':
case 'O':
c = '6';
break;
case 'P':
case 'Q':
case 'R':
case 'S':
c = '7';
break;
case 'T':
case 'U':
case 'V':
c = '8';
break;
case 'W':
case 'X':
case 'Y':
case 'Z':
c = '9';
break;
}
return c;
}
int main() {
char str[100];
char *uppr;
while(1){
printf("Enter a telephone number using letterss (EXIT to quit): The corresponding telephone number is: \n");
gets(str);
if(strcmp(str,"EXIT")==0)
break;
int i=0;
for(i=0;i<8;i++){
if(i==3){
printf("-");
}
if(str[i]==' ')
continue;
if(str[i]>='a' && str[i]<='z'){
str[i]=str[i]-32;
}
printf("%c\n",getNumber(str[i]));
}
}
return 0;
}
#include <stdio.h>
#include <string.h>
char getNumber(char aC) {
char c = ' ';
switch (aC) {
case 'A':
case 'B':
case 'C':
c = '2';
break;
case 'D':
case 'E':
case 'F':
c = '3';
break;
case 'G':
case 'H':
case 'I':
c = '4';
break;
case 'J':
case 'K':
case 'L':
c = '5';
break;
case 'M':
case 'N':
case 'O':
c = '6';
break;
case 'P':
case 'Q':
case 'R':
case 'S':
c = '7';
break;
case 'T':
case 'U':
case 'V':
c = '8';
break;
case 'W':
case 'X':
case 'Y':
case 'Z':
c = '9';
break;
}
return c;
}
int main() {
char str[100];
char *uppr;
while(1){
printf("\nEnter a telephone number using letterss (EXIT to quit): \n");
gets(str);
if(strcmp(str,"EXIT")==0)
break;
printf("The corresponding telephone number is:\n");
int i=0;
for(i=0;i<8;i++){
if(i==3){
printf("-");
}
if(str[i]==' ')
continue;
if(str[i]>='a' && str[i]<='z'){
str[i]=str[i]-32;
}
printf("%c",getNumber(str[i]));
}
}
printf("Bye Bye");
return 0;
}

Note : If you like my answer please rate and help me it is very Imp for me
i'm trouble getting my program to print this output and repeat until asked to quit the...
I'm having trouble getting a certain output with my program Here's my output: Please input a value in Roman numeral or EXIT or quit: MM MM = 2000 Please input a value in Roman numeral or EXIT or quit: mxvi Illegal Characters. Please input a value in Roman numeral or EXIT or quit: MXVI MXVI = 969 Please input a value in Roman numeral or EXIT or quit: EXIT Illegal Characters. Here's my desired output: Please input a value in...
I'm having trouble getting my program to output this statement Enter a sentence: Test! There are 5 total characters. There are 1 vowel. There are 1 UPPERCASE letters. There are 3 lowercase letters. There are 1 other characters. Here's my code: #include<string.h> #include<stdio.h> #include<stdbool.h> int main() { char str[100]; int i; int vowels=0; int UC; int LC; int Others; int c; printf("Enter a sentence: \n"); gets(s); LC=countLC(&s); UC=countUC(&s); Others=countOthers(&s); printf("There are %d total characters.\n", ; for(i=0; i<strlen(str); i++){ if(isVowel(str[i])) vowels++;...
Can someone help me fix my C code. I am getting segmentation fault along with missing termination " /* These are the included libraries. */ #include #include #include #include void printTriangle(char *str); int main() { char sentence[81]; int done = 0; while(done != 1) { printf("Please enter the sentence or quit: "); fgets(sentence, 80, stdin); if(strcmp(sentence, "quit") == 0) done = 1; else printTriangle(sentence); } } void printTriangle(char *str) { int index = 0; int line = 1; int i;...
I'm having trouble getting my program to print shapes For example: Which shape (L-line, T-triangle, R-rectangle): L Enter an integer length between 1 and 25: 13 ************* Which shape (L-line, T-triangle, R-rectangle): t Enter an integer base length between 3 and 25: 5 * ** *** **** ***** Which shape (L-line, T-triangle, R-rectangle): r Enter an integer width and height between 2 and 25: 4 5 **** **** **** **** **** Here's my code: #include <stdio.h> #include <ctype.h> const int...
I'm having trouble getting my program to output What is your first name? damion what is your last name? anderson damion, Your first name is 6 characters Your last name, anderson, is 8 characters Your name in reverse is: noimad nosredna This is my code so far: #include <stdlib.h> #include <stdio.h> void sizeOfName(char** name); void printSizeOfName(int *first, int *last, char** name); void reverseString(int *first, int *last, char** name); int main() { char** name; name = (char**)malloc(2*sizeof(char*)); name[0] = (char*)malloc(100*sizeof(char)); name[1]...
Here is a serial program in C and parallel program in OpenMP that takes in a string as input and counts the number of occurrences of a character you choose. Why is the runtime for the output for the OpenMP parallel program much longer? Serial Program #include <stdio.h> #include <string.h> #include <time.h> int main(){ char str[1000], ch; int i, frequency = 0; clock_t t; struct timespec ts, ts2; printf("Enter a string: "); gets(str); int len = strlen(str); printf("Enter a character...
#include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here. */ int GetNumOfNonWSCharacters(const char usrStr[]) { int length; int i; int count = 0; char c; length=strlen(usrStr); for (i = 0; i < length; i++) { c=usrStr[i]; if ( c!=' ' ) { count++; } } return count; } int GetNumOfWords(const char usrStr[]) { int counted = 0; // result // state: const char* it = usrStr; int inword = 0; do switch(*it)...
The following code is a C Program that is written for encrypting
and decrypting a string. provide a full explanation of the working
flow of the program.
#include <stdio.h> int main() { int i, x; char str[100]; printf("\n Please enter a valid string: \t"); gets (str); printf ("\n Please choose one of the following options: \n"); printf ("1 = Encrypt the given string. \n"); printf("2 = Decrypt the entered string. \n"); scanf("%d",&x); // using switch case statements switch (x) {...
Language is in C. Need help troubleshooting my code Goal of code: * Replace strings with a new string. * Append an s to the end of your input string if it's not a keyword. * Insert a period at the end, if you have an empty input string do not insert a period Problems: //Why does my code stop at only 2 input strings //If I insert a character my empty string case works but it's still bugged where...
I'm having trouble rounding the numbers i'm getting in my output here's my code: #include<stdio.h> int main() { char gender; float a1, a2, a3, a4, a5; float waistmeasurement, wristmeasurement, hipmeasurement, forarmmeasurement; float B, bodyweight, Bodyfat, Bodyfatpercentage; printf("This program determines the body fat of a person.Enter your gender (f|F|m|M): "); scanf("%c", &gender); printf("\n"); if(gender=='F' || gender=='f'){ printf("Enter body weight (in pounds): \n"); scanf("%f", &bodyweight); printf("Enter wrist measurement at fullest point (in inches): \n"); scanf("%f", &wristmeasurement); printf("Enter waist measurement at...