Carnby1021

Untitled

Mar 15th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.29 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<conio.h>
  4. #include<stdlib.h>
  5.  
  6. int dodaj(int,int);
  7. int odejmij(int,int);
  8. int mnozenie(int,int);
  9. float dzielenie(float,float);
  10. void wybor(char *);
  11.  
  12. int main(){
  13.     int a,b;
  14.     char x,y;
  15.     for(;;){
  16.     printf("Podaj operacje arytmetyczna:");
  17.     x=_getch();
  18.  
  19.     switch(x){
  20.         case'+':
  21.         printf("\nPodaj 1 liczbe: ");
  22.         scanf_s("%d",&a);
  23.         printf("Podaj 2 liczbe: ");
  24.         scanf_s("%d",&b);
  25.         printf("%d+%d=%d",a,b,dodaj(a,b));
  26.         break;
  27.  
  28.         case'-':
  29.             printf("\nPOdaj 1 liczbe: ");
  30.             scanf_s("%d",&a);
  31.             printf("podaj 2 liczbe: ");
  32.             scanf_s("%d",&b);
  33.             printf("%d-%d=%d",a,b,odejmij(a,b));
  34.             break;
  35.  
  36.  
  37.         case'*':
  38.             printf("\nPodaj 1 liczbe: ");
  39.             scanf_s("%d",&a);
  40.             printf("podaj 2 liczbe: ");
  41.             scanf_s("%d",&b);
  42.             printf("%d*%d=%d",a,b,mnozenie(a,b));
  43.             break;
  44.            
  45.         case'/':
  46.                 printf("\nPodaj 1 liczbe: ");
  47.             scanf_s("%f",&a);
  48.             printf("podaj 2 liczbe: ");
  49.             scanf_s("%f",&b);
  50.             printf("%f/%f=%f",a,b,dzielenie(a,b));
  51.             break;
  52.  
  53.  
  54.  
  55.                
  56.             default: printf("Nieznana opcja");exit(0);
  57.     }
  58.     getchar();getchar();
  59.     system("cls");
  60.     }
  61. return 0;
  62. }
  63.  
  64. int dodaj(int a,int b){
  65.     return a+b;
  66. }
  67. int odejmij(int a,int b){
  68.     return a-b;
  69. }
  70. int mnozenie(int a,int b){
  71.     return a*b;
  72. }
  73. float dzielenie(float a,float b){
  74.     return a/b;
  75. }
Add Comment
Please, Sign In to add comment