Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- float z,x,y;
- char c;
- int main()
- {
- printf(">>>KALKULATOR<<<\n");
- printf("PIERWSZA LICZBA: "); scanf("%f",&x);
- printf("DRUGA LICZBA: "); scanf("%f",&y);
- getchar();
- printf("Wybierz: \n");
- printf("1 Dodawanie \n");
- printf("2 Odejmowanie \n");
- printf("3 Mnozenie \n");
- printf("4 Dzielenie \n");
- printf("Podaj nr operacji ktory chcesz wykonac: ");
- getchar(c);
- switch(c)
- {
- case '1': z=x+y; printf("Wynik to: %.1f\n",z);
- break;
- case '2': z=x-y; printf("Wynik to: %.1f\n",z);
- break;
- case '3': z=x*y; printf("Wynik to: %.1f\n",z);
- break;
- case '4': z=x/y;
- if(y==0)
- printf("Nie mozna dzielic przez 0");
- else
- printf("Wynik to: %.2f\n",z);
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement