1

//Enter phone number: 1-800-COL-LECT
//1-800-265-5328
Im trying to input the dash right after COL and before LECT. Please help

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	char ch;
	printf("Enter Phrase\n");
	
	while((ch=getchar())!='\n')
		
	{
		if ((ch=='1'))
			printf("1-800-");
		
		else if((ch=='A')||(ch=='B')||(ch=='C'))
			printf("2");
		
		else if ((ch=='D')||(ch=='E')||(ch=='F'))
			printf("3");
		
		else if ((ch=='G')||(ch=='H')||(ch=='I'))
			printf("4");
		
		else if ((ch=='J')||(ch=='K')||(ch=='L'))
			printf("5");
		
		else if ((ch=='M')||(ch=='N')||(ch=='O'))
			printf("6");
		
		else if((ch=='P')||(ch=='Q')||(ch=='R')||(ch=='S'))
			printf("7");
		
		else if((ch=='T')||(ch=='U')||(ch=='V'))
			printf("8");
		
		else if((ch=='W')||(ch=='X')||(ch=='Y')||(ch=='Z'))
			printf("9");
	
	}
	
	
	return 0;
}

//Enter phone number: 1-800-COL-LECT
//1-800-265-5328

4
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by alex1050
0

Hello alex1050,
Try giving if-else statement for '-' also. I think then it would work.

Edited by Arbus: n/a

0

Not really a question?? Explain what u want properly.. The code above shows me nothing except that you have it set up like a telephone thats all.. and it prints a corresponding number when the person types a letter..

What exactly do u want?

you can do something like after the first character is pressed, printf("-") then after 3 characters is pressed do the same and then another three

0

Not really a question?? Explain what u want properly.. The code above shows me nothing except that you have it set up like a telephone thats all.. and it prints a corresponding number when the person types a letter..

What exactly do u want?

you can do something like after the first character is pressed, printf("-") then after 3 characters is pressed do the same and then another three

yeah triumphost thats what im trying to do...how can i achieve this?

Edited by alex1050: n/a

0

yeah triumphost thats what im trying to do...how can i achieve this?

You are allowed to read more than just the last post. Arbus gave you the solution.

0

You are allowed to read more than just the last post. Arbus gave you the solution.

Walt im kind of confused to executed this can you help please. thanks

0

Hello alex1050,
Try giving if-else statement for '-' also. I think then it would work.

Alright thanks Arbus

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.