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.
Answer Posted / 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 View All Answers
Why do we write return 0 in c?
What does printf does?
Explain data types & how many data types supported by c?
What is the purpose of & in scanf?
How can I dynamically allocate arrays?
What is main () in c?
Explain what is the difference between #include and #include 'file' ?
Write a program with dynamically allocation of variable.
Can you assign a different address to an array tag?
What is the difference between arrays and pointers?
What is the difference between single charater constant and string constant?
What happens if header file is included twice?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
Is null always defined as 0(zero)?