Zeshin

task6

Jul 5th, 2021
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a, b;
  5. char c;
  6. double result;
  7. scanf("%d", &a);
  8. scanf("%d", &b);
  9. scanf(" %c", &c);
  10. //printf("%d%d%c", a, b, c);
  11. if(c == '+')
  12. {
  13. result = a + b;
  14. }else if(c == '-')
  15. {
  16. result = a - b;
  17. }else if(c == '*')
  18. {
  19. result = a * b;
  20. }else if( c == '/' && b !=0)
  21. {
  22. result = (double) a / b;
  23. }else
  24. {
  25. printf("Invalid argument or tried to divide by 0");
  26. return 0;
  27. }
  28. printf("%.2f", result);
  29. return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment