Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int dodaj(int a, int b );
- int odejmij(int a, int b );
- int pomnoz(int a, int b );
- float podziel(int a, int b );
- int main()
- {
- int a, b;
- int opcja;
- cout<< "podaj pierwszaq liczbe"<<endl;
- cin >> a;
- cout<< "podaj druga liczbe"<<endl;
- cin >> b;
- while (opcja!=0)
- {
- cout<< "1 dodaj"<<endl;
- cout << "2 odejmij"<<endl;
- cout<< "3 pomnoz"<<endl;
- cout<< "4 podziel"<<endl;
- cout<< "5 powieksz a o 1"<<endl;
- cout<< "6 pomniejsz a o 1"<<endl;
- cout<< "0 zakoncz program"<<endl;
- cout<<"wybierz opcje"<<endl;
- cin >>opcja;
- switch (opcja )
- {
- case 1: cout<<dodaj(a,b)<<endl;
- break;
- case 2: cout<<odejmij(a,b)<<endl;
- break;
- case 3: cout<<pomnoz(a,b)<<endl;
- break;
- case 4:
- { while (b==0) {
- cout<<"nie wolno dzielic przez 0 "<<endl;
- cout<< "podaj b"<<endl;
- cin>>b;
- }
- cout<<podziel(a,b)<<endl;
- }
- break;
- case 5: {
- a++;
- cout<<"a= "<<a<<endl;
- }
- break;
- case 6:
- {
- a--;
- cout<<"a= "<<a<<endl;
- }
- break;
- }
- }
- }
- int dodaj(int a, int b )
- { int wynik=0;
- return wynik=a+b;
- }
- int odejmij(int a, int b )
- { int wynik=0;
- return wynik=a-b;
- }
- int pomnoz(int a, int b )
- { int wynik=0;
- return wynik=a*b;
- }
- float podziel(int a, int b )
- { float wynik=0;
- return wynik=(a/b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement