/* calc.c  - prints the result of arithmetic expression in */
/*           arguments 1-3, e.g. calc 75 / 15 would print 5 */
/*           Written by D McSweeney 1990                    */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int op1, op2;

if(argc != 4){
   fprintf(stderr, "Wrong number of arguments\n");
   exit(1);
   }

op1 = atoi(argv[1]);   /* function atoi(str) returns int value of str */
op2 = atoi(argv[3]);

switch(*argv[2]){
   case '+':
      printf("%d", op1 + op2);
      break;
   case '-':
      printf("%d", op1 - op2);
      break;
   case '*':
      printf("%d", op1 * op2);
      break;
   case '/':
      printf("%d", op1 / op2);
      break;
   default:
      fprintf(stderr, "Unknown operation");
      break;
   }
}

