Advertisement
Guest User

task2

a guest
Feb 21st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int Addition(int x, int y) {
  5.     return x+y;
  6. }
  7.  
  8. int Substraction(int x, int y) {
  9.     return x-y;
  10. }
  11.  
  12. int Multiplication(int x, int y) {
  13.     return x*y;
  14. }
  15.  
  16. int Division(int x, int y) {
  17.     return x / y;
  18. }
  19.  
  20. int Square(int x) {
  21.     return x * x;
  22. }
  23.  
  24. int Square_Root(int x) {
  25.     return sqrt(x);
  26. }
  27.  
  28. int main(void) {
  29.     int choice;
  30.     int x, y;
  31.  
  32.     scanf("%d", &choice);
  33.     printf("%c", choice);
  34.  
  35.     switch(choice) {
  36.         case 1:
  37.             scanf("%d %d", &x, &y);
  38.             printf("%d", Addition(x, y));
  39.             break;
  40.         case 2:
  41.             scanf("%d %d", &x, &y);
  42.             printf("%d", Substraction(x, y));
  43.             break;
  44.         case 3:
  45.             scanf("%d %d", &x, &y);
  46.             printf("%d", Multiplication(x, y));
  47.             break;
  48.         case 4:
  49.             scanf("%d %d", &x, &y);
  50.             printf("%d", Division(x, y));
  51.             break;
  52.         case 5:
  53.             scanf("%d", &x);
  54.             printf("%d", Square(x));
  55.             break;
  56.         case 6:
  57.             scanf("%d", &x);
  58.             printf("%d", Square_Root(x));
  59.             break;
  60.         default:
  61.             break;
  62.     }
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement