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