Advertisement
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>
- #define PI 3.14159265
- double dodaj(double,double);
- double odejmij(double,double);
- double mnozenie(double,double);
- double dzielenie(double,double);
- void interfejs(char);
- double podaj_liczby(char *);
- char wczytaj_znak();
- double sinus(double);
- double cosinus(double);
- int main(){
- char a;
- for(;;){
- a=wczytaj_znak();
- interfejs(a);
- }
- return 0;
- }
- double dodaj(double a,double b){
- return a+b;
- }
- double odejmij(double a,double b){
- return a-b;
- }
- double mnozenie(double a,double b){
- return a*b;
- }
- double dzielenie(double a,double b){
- return (double)a/b;
- }
- void interfejs(char x){
- double a,b;
- switch(x){
- case'+':
- a=podaj_liczby("Podaj pierwsza liczbe: ");
- b=podaj_liczby("Podaj druga liczbe: ");
- printf("%f+%f=%f",a,b,dodaj(a,b));
- break;
- case'-':
- a=podaj_liczby("Podaj pierwsza liczbe: ");
- b=podaj_liczby("Podaj druga liczbe: ");
- printf("%f-%f=%f",a,b,odejmij(a,b));
- break;
- case'*':
- a=podaj_liczby("Podaj pierwsza liczbe: ");
- b=podaj_liczby("Podaj druga liczbe: ");
- printf("%f*%f=%f",a,b,mnozenie(a,b));
- break;
- case'/':
- a=podaj_liczby("Podaj pierwsza liczbe: ");
- b=podaj_liczby("Podaj druga liczbe: ");
- printf("%f/%f=%f",a,b,dzielenie(a,b));
- break;
- case's':
- a=podaj_liczby("Podaj pierwsza liczbe: ");
- b=podaj_liczby("Podaj druga liczbe: ");
- printf("sinus%f = %g\n",a,sinus(a));
- printf("cosinus%f = %g\n",b,cosinus(b));
- break;
- case'e':
- exit(0);
- break;
- default: printf("Nieznana opcja");
- }
- getchar();getchar();
- system("cls");
- }
- double podaj_liczby(char*liczba){
- double a;
- printf("%s",liczba);
- scanf_s("%f",&a);
- return a;
- }
- char wczytaj_znak(){
- char x;
- printf("Podaj operacje arytmetyczna:");
- x=_getch();
- return x;
- }
- double sinus(double a){
- double val,wynik;
- val = PI / 180;
- wynik = sin(a*val);
- return wynik;
- }
- double cosinus(double b){
- double val,wynik;
- val = PI / 180;
- wynik = cos(b*val);
- return wynik;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement