Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int wybor,a,b;
- float dodawanie(int a, int b)
- {
- return a+b;
- }
- float odejmowanie(int a, int b)
- {
- return a-b;
- }
- float mnozenie(int a, int b)
- {
- return a*b;
- }
- float dzielenie(int a, int b)
- {
- return a/b;
- }
- float potegowanie(int a, int b)
- {
- return pow(a,b);
- }
- int main()
- {
- cout<<"Kalkulator v1"<<endl;
- do
- {
- cout<<"[1]Dodawanie"<<endl;
- cout<<"[2]Odejmowanie"<<endl;
- cout<<"[3]Mnozenie"<<endl;
- cout<<"[4]Dzielenie"<<endl;
- cout<<"[5]Potegowanie"<<endl;
- cout<<"[6]Zamknij program"<<endl;
- cout<<"Co chcesz zrobic?"<<endl;
- cin>>wybor;
- switch(wybor)
- {
- case 1:
- cout<<"Podaj pierwsza liczbe: "<<endl;
- cin>>a;
- cout<<"Podaj druga liczbe: "<<endl;
- cin>>b;
- cout<<"Wynik: "<<dodawanie(a,b)<<endl;
- break;
- case 2:
- cout<<"Podaj pierwsza liczbe: "<<endl;
- cin>>a;
- cout<<"Podaj druga liczbe: "<<endl;
- cin>>b;
- cout<<"Wynik: "<<odejmowanie(a,b)<<endl;
- break;
- case 3:
- cout<<"Podaj pierwsza liczbe: "<<endl;
- cin>>a;
- cout<<"Podaj druga liczbe: "<<endl;
- cin>>b;
- cout<<"Wynik: "<<mnozenie(a,b)<<endl;
- break;
- case 4:
- cout<<"Podaj pierwsza liczbe: "<<endl;
- cin>>a;
- cout<<"Podaj druga liczbe: "<<endl;
- cin>>b;
- cout<<"Wynik: "<<dzielenie(a,b)<<endl;
- break;
- case 5:
- cout<<"Podaj liczbe, ktora chcesz spotegowac: "<<endl;
- cin>>a;
- cout<<"Podaj potege, do ktorej chcesz podniesc liczbe: "<<endl;
- cin>>b;
- cout<<"Wynik: "<<potegowanie(a,b)<<endl;
- break;
- default:
- cout<<"Nieprawidlowy wybor!!!"<<endl;
- }
- } while(wybor=!5);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment