if i press 1 on c++ show i
if i press 2 on c++ show l
if i press 3 on c++ show o
if i press 4 on c++ show v
if i press 5 on c++ show e
if i press 6 on c++ show u
How to write c++ program???
#include %26lt;iostream.h%26gt;
#include %26lt;conio.h%26gt;
#include %26lt;process.h%26gt;
main()
{
char c;
clrscr();
cout%26lt;%26lt;"Press 0 to exit\n";
do
{
c=getch();
switch(c)
{
case '0': exit(0);
case '1': cout%26lt;%26lt;"I";break;
case '2': cout%26lt;%26lt;"L";break;
case '3': cout%26lt;%26lt;"o";break;
case '4': cout%26lt;%26lt;"v";break;
case '5': cout%26lt;%26lt;"e";break;
case '6': cout%26lt;%26lt;"U";break;
}
} while (1);
return 0;
}
Reply:void main
{ int ch;
cout%26lt;%26lt;"enter number";
cin%26gt;%26gt;ch;
switch(ch)
{ case 1: cout%26lt;%26lt; "i";break;
case 2:cout%26lt;%26lt;"l";break;
case 3:cout%26lt;%26lt;"o"break;
case 4: cout%26lt;%26lt;"v";break;
case 5: cout%26lt;%26lt;"e";break;
case 6:cout%26lt;%26lt;"u";break;
default : cout%26lt;%26lt;"wrong number";break;
}
getch()
}
Reply:Hi I hope the following code will help u out, though u may need to rectify some syntax error.
#include %26lt;iostream.h%26gt;
int var1;
void main()
{
cout%26lt;%26lt;"Press any key form 1 to 6 :: "%26lt;%26lt;endl%26lt;%26lt;endl;
cin%26gt;%26gt;var1;
if var1 = '1';
cout%26lt;%26lt;"i"%26lt;%26lt;endl;
elseif var1 = '2';
cout%26lt;%26lt;"I"%26lt;%26lt;endl;
elseif var1 = '3';
cout%26lt;%26lt;"o"%26lt;%26lt;endl;
elseif var1 = '4';
cout%26lt;%26lt;"v"%26lt;%26lt;endl;
elseif var1 = '5';
cout%26lt;%26lt;"e"%26lt;%26lt;endl;
elseif var1 = '6';
cout%26lt;%26lt;"u"%26lt;%26lt;endl;
endif.
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment