10th C++ problem
write a program similar to mobile key system?
Like say you want to send a message to someone
then if you press 2 one times then press enter it will display a,if 2 times then enter it will display b,if three then c
similarly upto key 9 you have to make this program
One constraint:Say if i press 2 then press 3 without pressing enter it should display error 😉
Note:There is no need of graphic interface :just print output on console
Like say you want to send a message to someone
then if you press 2 one times then press enter it will display a,if 2 times then enter it will display b,if three then c
similarly upto key 9 you have to make this program
One constraint:Say if i press 2 then press 3 without pressing enter it should display error 😉
Note:There is no need of graphic interface :just print output on console
Replies
-
gaurav.bhorkarThat's an interesting program. I'll try that after I finish my college today.
-
Manish GoyalI am waiting Gaurav.
This program was asked in a coding competition that i had participated last month -
silverscorpionI think this can be easily done by a simple switch case since only one character is to be deduced from the input at a time. The code goes something like this:
char ans; int a;
You can also keep a flag variable and depending on whether it is one or zero, you can assign either capital letters or small letters too.. this will do it. What do you say??
scanf("%d",&a);
switch (a)
{
case 2: ans='a'; break; case 22: ans='b'; break; case 222: ans='c'; break;
case 3: ans='d'; break; case 33: ans='e'; break; case 333: ans='f'; break;
case 4: ans='g'; break; case 44: ans='h'; break; case 444: ans='i'; break;
case 5: ans='j'; break; case 55: ans='k'; break; case 555: ans='l'; break;
case 6: ans='m'; break; case 66: ans='n'; break; case 666: ans='o'; break;
case 7: ans='p'; break; case 77: ans='q'; break; case 777: ans='r'; break; case 7777: ans]='s'; break;
case 8: ans='t'; break; case 88: ans='u'; break; case 888: ans='v'; break;
case 9: ans='w'; break; case 99: ans='x'; break; case 999: ans='y'; break; case 9999: ans='z'; break;
default: printf("Error. Invalid sequence.");
} -
Manish GoyalQuite nice attempt scorpion
but i want that if someone press 2 then if without pressing enter he presses 3 or
something else immediately it will display error without waiting for you to press enter -
gaurav.bhorkarI was thinking quite similar to silverscorpion. The break statement after each case is missing in his program. Also print the character after the switch ends.
-
Manish Goyalcome on guys keep thinking
frankly saying i was also not able to make this program during that competition but after that i tried this at home and i made it -
Manish GoyalSo here is the code for this..if anyone can make it more simpler then he is welcome
#include
#include void main() { char ch; char one[]={'a','b','c'}; char two[]={'d','e','f'}; char three[]={'g','h','i'}; char four[]={'j','k','l'}; char five[]={'m','n','o'}; char six[]={'p','q','r','s'}; char seven[]={'t','u','v'}; char eight[]={'w','x','y','z'}; ch=getch(); int c=ch; int count=-1,store[1]; while(c!=13) { if(count==-1) { store[0]=c; } if(c!=store[0]&&c!=13) { cout<<"Error"< -
manav1hi!! Goyal ,That's an interesting program
-
Manish Goyalhi manav
First of all welcome to ce
second just be active on ce you will find more interesting things here -
HImanshu_SharmaYeah Gaurav you are right,,,i hv found many interesting things here...
my question can u make a folder whch dont hav name?????? -
Manish Goyal@ Himanshu .Yes we can but this is not the right place to ask your question.
just create a new thread in appropriate section
anyway .. create a new folder and click on rename and press alt+0160
You will get a folder with no name -
imlitoshi11goyal i like ur code.....hats off
-
HImanshu_Sharmaok i'l remember actually m new na so,,,bt i hv another solution for it...
-
HImanshu_Sharmadear its nt working,,,space bar shud be also pressed wid alt and this code...get it
-
Manish Goyal@imlitoshi thanks for appreciation
@ himanshu okk Sir and please avoid sms text .
You are reading an archived discussion.
Related Posts
1. i want to know the basic process of transformer so that i can have a fair idea???/
Pardon my ignorance if there are awards for what I'm talking about.
We have Oscars for movies, Grammy for music and now I'm thinking why aren't there any major awards...
I need help creating a Gui that can optimize traffic signal timings for a set of traffic lights at the intersection of two roads. The goal is to minimize the...
hi i'm student of EEE(2'nd year)😀, i would like to do some projects..i don't have any idea on which topic i can do ma project😕.. i don't have that much...
Hello CEans,
I want tutorials for deform 2d & 3d. 😔