#include<>
int calc(int,int,char);
void main()
{
int a,b;
char c;
printf("enter 2 nos");
scanf("%d%d",&a,&b);
printf("enter op");
scanf("%s",&c);
printf("the ans is %d\n",calc(a,b,c));
}
int calc(int a,int b,char c)
{
int ans;
switch(c)
{
case'+':ans=a+b;break;
case'-':ans=a-b;break;
}
return ans;
}
why does this program give the output as b...it works when i give a, b and c as global variables...what change should i do if i want them as local variables...using functions