stanzin otsal
New Member
- Joined
- Dec 26, 2010
- Messages
- 3
- Reaction score
- 0
- Points
- 1
//call by value example
int calc(int var1,int var2,char oper);
main()
{
int num1,num2;
char operator;
printf(";enter two no.s and an operator\n");
scanf("%d%d%d",&num1,&num2,&operator);
calc(num1,num2,operator);
getch();
}
calc(var1,var2,oper)
{
int var1,var2;
char oper;
switch(oper)
{
case '*':
printf("%d",var1*var2);
break;
case '/':
printf("%d",var1/var2);
break;
case '-':
printf("%d",var1-var2);
break;
case'+':
printf("%d",var1-var2);
break;
default:
printf(" do as you are told \n");
}
int calc(int var1,int var2,char oper);
main()
{
int num1,num2;
char operator;
printf(";enter two no.s and an operator\n");
scanf("%d%d%d",&num1,&num2,&operator);
calc(num1,num2,operator);
getch();
}
calc(var1,var2,oper)
{
int var1,var2;
char oper;
switch(oper)
{
case '*':
printf("%d",var1*var2);
break;
case '/':
printf("%d",var1/var2);
break;
case '-':
printf("%d",var1-var2);
break;
case'+':
printf("%d",var1-var2);
break;
default:
printf(" do as you are told \n");
}