i just want to put more than one character through the (get char) or by any other way, this is a simple calculator program using switch cases condition but cant choose a case with more than one input to the getch
function for ex: 10,11....
#include <stdio.h>
#include <conio.h>
void plus_func();
void menus_func();
void mul_func();
void div_func();
void modulus_func();
void shiftleft_func();
void shiftright_func();
void and_func();
void or_func();
void not_func();
void doubleand_func();
void doubleor_func();
void notequal_func();
void xor_func();
void main(void){
int x,y, res;
int m;
int op1;
int op2;
int op3;
int i=0;
int k;
while(i==0){
printf("Enter any key to start the calculator function program or escape to exit it \n");
k=getch();
if(k!=0x1b)
{
printf("enter the first num or press escape to exit \n");
x=getch();
if(x==0x1b)
{
break;
}
else
{
op1=x-48;
}
printf("enter the second num or press escape to exit \n");
y=getch();
if(y==0x1b)
{
break;
}
else
{
op2=y-48;
}
printf("enter the type of the operation \n",m);
m=getch();
if(m==0x1b)
{
break;
}
else
{
op3=m-48;
}
switch(op3)
{
case 1: plus_func(op1,op2);break;
case 2: menus_func(op1,op2);break;
case 3: mul_func(op1,op2);break;
case 4: div_func(op1,op2);break;
case 5: modulus_func(op1,op2);break;
case 6: shiftleft_func(op1,op2);break;
case 7: shiftright_func(op1,op2);break;
case 8: and_func(op1,op2);break;
case 9: or_func(op1,op2);break;
case 10: not_func(op1,op2);break;
case 11: doubleand_func(op1,op2);break;
case 12: doubleor_func(op1,op2);break;
case 13: notequal_func(op1,op2);break;
case 14: xor_func(op1,op2);break;
default: printf("error");
break;
}
}
else
{
break;
}
}
}
void plus_func(int a, int b)
{
int c;
c=a+b;
printf("the result is %d \n",c);
}
void menus_func(int a, int b)
{
int c;
c=a-b;
printf("the result is %d \n",c);
}
void mul_func(int a, int b)
{
int c;
c=a*b;
printf("the result is %d \n",c);
}
void div_func(int a, int b)
{
int c;
c=a/b;
printf("the result is %d \n",c);
}
void modulus_func(int a, int b)
{
int c;
c=a%b;
printf("the result is %d \n",c);
}
void shiftleft_func(int a, int b){
int c;
c=a<<b;
printf("the result is %d \n",c);
}
void shiftright_func(int a, int b)
{
int c;
c=a>>b;
printf("the result is %d \n",c);
}
void and_func(int a, int b)
{
int c;
c=a&b;
printf("the result is %d \n",c);
}
void or_func(int a, int b)
{
int c;
c=a|b;
printf("the result is %d \n",c);
}
void not_func(int a, int b)
{
int c;
c=a+b;
c=~c;
printf("the result is %d \n",c);
}
void doubleand_func(int a, int b)
{
int c;
c=a&&b;
printf("the result is %d \n",c);
}
void doubleor_func(int a, int b)
{
int c;
c=a||b;
printf("the result is %d \n",c);
}
void notequal_func(int a, int b)
{
int c;
c=a+b;
c=!c;
printf("the result is %d \n",c);
}
void xor_func(int a, int b)
{
int c;
c=a^b;
printf("the result is %d \n",c);
}