Seach
INTEGER CALCULATOR USING FUNCTION
#include
#include
void main()
{
int a,b;
char choice;
//clrscr();
void call(int,int,char);
clrscr();
printf("+:addition\n-:subtraction\n*multiplication\n/:division\n%:modulo division");
printf("\nchoice");
scanf("%c",&choice);
printf("enter the numbers to perform arithamatic operations");
scanf("%d%d",&a,&b);
//scanf("%c",&choice);
calling(a,b,choice);
getch();
}
void call(int a,int b,char ch)
{
int x=a,y=b;
char c=ch;
//printf("enter the choice:");
//scanf("%c",&c);
switch(c)
{
case '+':
printf("addition %d +%d =%d",x,y,x+y);
break;
case '-':
printf("subtraction %d - %d =%d",x,y,x-y);
break;
case '*':
printf("multiplication %d * %d =%d",x,y,x*y);
break;
case '/':
printf("division %d/%d=%f",x,y,(float)x/y);
break;
case '%':
printf("modulo division %d % %d =%d",x,y,x%y);
break;
default:
printf("invalid choice:");
break;
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment