Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int simple_multiply(void)
  4. {
  5. int a, b;
  6. int ret;
  7. ret = scanf("%d %d", &a, &b);
  8. int tulos = a * b;
  9. printf("%d\n", tulos);
  10. return 0;
  11. }
  12.  
  13.  
  14. float simple_math(void)
  15. {
  16. float n1, n2;
  17. char operaattori;
  18. float tulos;
  19. int ret;
  20. ret = scanf("%d, %c, %d", &n1, &operaattori, &n2);
  21.  
  22. if (operaattori == '+')
  23. {
  24. tulos = n1 + n2;
  25. printf("%.1f\n", tulos);
  26. }
  27.  
  28. else if (operaattori == '-')
  29. {
  30. tulos = n1 - n2;
  31. printf("%.1f\n", tulos);
  32. }
  33.  
  34. else if (operaattori == '/')
  35. {
  36. tulos = n1 / n2;
  37. printf("%.1f\n", tulos);
  38. }
  39.  
  40. else
  41. {
  42. printf("ERR\n");
  43. }
  44.  
  45. return 0;
  46. }
  47.  
  48.  
  49.  
  50.  
  51. int main(void)
  52. {
  53. /*simple_multiply();*/
  54. simple_math();
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement