fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int a, b;
  5. char c;
  6. printf("Enter 1 value:");
  7. int test = scanf("%d", &a);
  8. fseek(stdin,0,SEEK_END);
  9. printf("\nEnter 2 value:");
  10. test = scanf("%d", &b);
  11. fseek(stdin,0,SEEK_END);
  12. printf("\nEnter action you want to do with entered values[+,-,/,*]");
  13. scanf("%c", &c);
  14.  
  15. switch(c)
  16. {
  17. case '+':
  18. printf("%d", a + b);
  19. break;
  20. case '-':
  21. printf("%d", a - b);
  22. break;
  23. case '*':
  24. printf("%d", a * b);
  25. break;
  26. case '/':
  27. printf("%d", a / b);
  28. break;
  29. default:
  30. printf("\nEntered operator is not valid");
  31. }
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 2252KB
stdin
4
4
+
stdout
Enter 1 value:
Enter 2 value:
Enter action you want to do with entered values[+,-,/,*]
Entered operator is not valid