BASIC CALCULATOR Program in C

Image result for c programming

BASIC CALCULATOR Program in C
Code:
  #include<stdio.h>
int main()
{
  int a,b;
  char o[1];
  scanf("%d",&a);
  scanf("%s",o);
  scanf("%d",&b);
  switch(o[0])
  {
    case '+':
          printf("The sum is %d",a+b);
          break;
    case '-':
          printf("The difference is %d",a-b);
          break;
    case '*':
          printf("The product is %d",a*b);
          break;
    case '/':
          printf("The quotient is %d",(int)(a/b));
          break;
    case '%':
          printf("The remainder is %d",(int)(a%b));
          break;
    default:
    printf("Invalid Input");
    break;
 
  }
  return 0;
}

No comments