//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

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

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

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?

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.

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

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

Alright thanks Arbus

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.