You are on page 1of 2

int add(int a,int b)

{
return a+b;
}
int sub(int a,int b)
{
return a-b;
}
int mul(int a,int b)
{
return a*b;
}
int div(int a,int b)
{
return a/b;
}
void main()
{
char sign[]={'+','-','*','/'};
int x=0,y=0,result=0;
while(1)
{
if(start_button())
{
while(start_button());
x++;
}
else if(stop_button())
{
while(stop_button());
y++;
}
printf("%d %c %d\n",x,sign[knob()/64],y);
if(digital(10))
{
while(digital(10));
if((knob()/64)==0)
{
result=add(x,y);
}
else if((knob()/64)==1)
{
result=sub(x,y);
}
else if((knob()/64)==2)
{
result=mul(x,y);
}
else if((knob()/64)==3)
{
result=div(x,y);
}
printf("Result = %d\n",result);
x=0;

y=0;
sleep(3.0);
}
sleep(0.1);
}
}

You might also like