Write a program in C to print the alphabets in order as on a
mobile phone.i.e:When 2 is pressed once 'a' prints and if it
is pressed two times 'b' prints and so on.we have to print
all the alphabets as on mobile phone like this.



Write a program in C to print the alphabets in order as on a mobile phone.i.e:When 2 is pressed onc..

Answer / balakrishna

void main()
{
int n;int i;int d[100]; char str[100];
clrscr();
printf("\nhow much text u want to print with
spaces...");
scanf("%d",&n);
printf("\nEnter ur message as assuming cellphone
keypad...eg:\npress 2 to print a");
for(i=0;i<n;i++)
{
scanf("%d",&d[i]);

switch(d[i])
{
case 2:
str[i]='a';
break;
case 22:
str[i]='b';
break;
case 222:
str[i]='c';
break;
case 3:
str[i]='d';
break;
case 33:
str[i]='e';
break;
case 333:
str[i]='f';
break;
case 4:
str[i]='g';
break;
case 44:
str[i]='h';
break;
case 444:
str[i]='i';
break;
case 5:
str[i]='j';
break;
case 55:
str[i]='k';
break;
case 555:
str[i]='l';
break;
case 6:
str[i]='m';
break;
case 66:
str[i]='n';
break;
case 666:
str[i]='o';
break;
case 7:
str[i]='p';
break;
case 77:
str[i]='q';
break;
case 777:
str[i]='r';
break;
case 7777:
str[i]='s';
break;
case 8:
str[i]='t';
break;
case 88:
str[i]='u';
break;
case 888:
str[i]='v';
break;
case 9:
str[i]='w';
break;
case 99:
str[i]='x';
break;
case 999:
str[i]='y';
break;
case 9999:
str[i]='z';
break;
case 1:
str[i]=' ';
break;
}

}
printf("\n ur message....%s",str);
getch();
}

Is This Answer Correct ?    6 Yes 4 No

Post New Answer

More C Interview Questions

Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given

0 Answers   XYZ,


If you know then define #pragma?

0 Answers  


a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor

0 Answers  


Explain how can you be sure that a program follows the ansi c standard?

0 Answers  


What is the difference between fread and fwrite function?

0 Answers  






how write a addtion of two single dimensional array using of pointer in c language?

3 Answers   DRDO,


What is the use of static variable in c?

0 Answers  


Explain spaghetti programming?

0 Answers  


What is const volatile variable in c?

0 Answers  


How to access or modify the const variable in c ?

16 Answers   HCL, HP,


What are run-time errors?

0 Answers  


What is the difference between a string and an array?

0 Answers  


Categories