Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- #include<conio.h>
- #include<stdlib.h>
- int dodaj(int,int);
- int odejmij(int,int);
- int mnozenie(int,int);
- float dzielenie(float,float);
- void wybor(char *);
- int main(){
- int a,b;
- char x,y;
- for(;;){
- printf("Podaj operacje arytmetyczna:");
- x=_getch();
- switch(x){
- case'+':
- printf("\nPodaj 1 liczbe: ");
- scanf_s("%d",&a);
- printf("Podaj 2 liczbe: ");
- scanf_s("%d",&b);
- printf("%d+%d=%d",a,b,dodaj(a,b));
- break;
- case'-':
- printf("\nPOdaj 1 liczbe: ");
- scanf_s("%d",&a);
- printf("podaj 2 liczbe: ");
- scanf_s("%d",&b);
- printf("%d-%d=%d",a,b,odejmij(a,b));
- break;
- case'*':
- printf("\nPodaj 1 liczbe: ");
- scanf_s("%d",&a);
- printf("podaj 2 liczbe: ");
- scanf_s("%d",&b);
- printf("%d*%d=%d",a,b,mnozenie(a,b));
- break;
- case'/':
- printf("\nPodaj 1 liczbe: ");
- scanf_s("%f",&a);
- printf("podaj 2 liczbe: ");
- scanf_s("%f",&b);
- printf("%f/%f=%f",a,b,dzielenie(a,b));
- break;
- default: printf("Nieznana opcja");exit(0);
- }
- getchar();getchar();
- system("cls");
- }
- return 0;
- }
- int dodaj(int a,int b){
- return a+b;
- }
- int odejmij(int a,int b){
- return a-b;
- }
- int mnozenie(int a,int b){
- return a*b;
- }
- float dzielenie(float a,float b){
- return a/b;
- }
Add Comment
Please, Sign In to add comment