Advertisement
youuw

kalkulator

Nov 1st, 2021
1,184
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 main(int argc, char **argv) {
  5.  
  6.     int wybor = 0;
  7.     float a, b;
  8.     printf("Podaj pierwsza liczbe: ");
  9.     scanf("%f", &a);
  10.     printf("Podaj druga liczbe: ");
  11.     scanf("%f", &b);
  12.     printf("Wybierz operacje arytmetyczna:\n");
  13.     printf("1. Dodawanie\n");
  14.     printf("2. Odejmowanie:\n");
  15.     printf("3. Mnozenie\n");
  16.     printf("4. Dzielenie\n");
  17.     printf("5. OR\n");
  18.     printf("6. XOR\n");
  19.     printf("7. AND\n");
  20.     scanf("%d", &wybor);
  21.     printf("\n");
  22.     if(wybor == 1) printf("%f + %f = %f",a,b,a+b);
  23.     else if(wybor == 2) printf("%f - %f = %f",a,b,a=b);
  24.     else if(wybor == 3) printf("%f * %f = %f",a,b,a*b);
  25.     else if(wybor == 4) printf("%f / %f = %f",a,b,a/b);
  26.     else if(wybor == 5) printf("%d OR %d = %d",(int)a,(int)b,(int)a|(int)b);
  27.     else if(wybor == 6) printf("%d XOR %d = %d",(int)a,(int)b,(int)a^(int)b);
  28.     else if(wybor == 7) printf("%d AND %d = %d",(int)a,(int)b,(int)a&(int)b);
  29.     else printf("Podano bledny numer wyboru!");
  30.     printf("\n");
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement