fork download
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. int operand1,operand2,rem;
  6. int n;
  7. printf("enter any two operands\n");
  8. scanf("%d %d",&operand1,&operand2);
  9. printf("enter any digit\n");
  10. scanf("%c",&n);
  11. switch(n)
  12. {
  13. case '+':
  14. printf("ADD\t%d+%d=%d",operand1,operand2,operand1+operand2);
  15. break;
  16. case '-':
  17. printf("SUB\t%d-%d=%d",operand1,operand2,operand1-operand2);
  18. break;
  19. case '*':
  20. printf("MUL\t%d*%d=%d",operand1,operand2,operand1*operand2);
  21. break;
  22. case '/':
  23. printf("DIV\t%d/%d=%d",operand1,operand2,operand1/operand2);
  24. break;
  25. case '%':
  26.  
  27. rem=operand1%operand2;
  28. printf("%d",rem);
  29. break;
  30. default:
  31. printf("enter any valid arithmetic operator");
  32. break;
  33. }
  34. return 0;
  35. }
  36.  
  37.  
Success #stdin #stdout 0s 5508KB
stdin
4 2
+
stdout
enter any two operands
enter any digit
enter any valid arithmetic operator