Advertisement
rootuss

k2

Nov 14th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <conio.h>
  4. #include <stdio.h>
  5.  
  6. using namespace std;
  7.  
  8. float suma(float pierwsza, float druga)
  9. {
  10.     return pierwsza + druga;
  11. }
  12.  
  13. float roznica(float pierwsza, float druga)
  14. {
  15.     return pierwsza - druga;
  16. }
  17.  
  18. float iloczyn(float pierwsza, float druga)
  19. {
  20.     return pierwsza * druga;
  21. }
  22.  
  23. void iloraz(float pierwsza, float druga)
  24. {
  25.     if(druga==0)
  26.             {
  27.                 cout<<"Nie dzilimy przez 0"<<endl;
  28.             }
  29.             else
  30.             {
  31.                 cout<<"Iloraz to: "<< pierwsza/druga;
  32.             }
  33.  
  34. }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. int main()
  42. {
  43.     float x, y;
  44.  
  45.     for(;;)
  46.     {
  47.  
  48.  
  49.     cout << "Podaj x i y" << endl;
  50.     cout<<"x= ";
  51.     cin>>x;
  52.     cout<<"y= ";
  53.     cin>>y;
  54.  
  55.  
  56.     cout<<"MENU GLOWNE"<<endl;
  57.     cout<<"************"<<endl;
  58.     cout<<"1. Dodawanie"<<endl;
  59.     cout<<"2. Odejmowanie"<<endl;
  60.     cout<<"3. Mnozenie"<<endl;
  61.     cout<<"4. Dzielenie"<<endl;
  62.     cout<<"5. Koniec"<<endl;
  63.     char wybor;
  64.     cout<<"Podaj numer dzialania: ";
  65.     wybor=getch();
  66.     cout<<endl;
  67.  
  68.    switch(wybor)
  69.     {
  70.     case '1':
  71.         {
  72.             cout<<"Suma to "<<suma(x,y);
  73.  
  74.         break;
  75.         }
  76.     case '2':
  77.         {
  78.         cout<<"Roznica to to "<<roznica(x,y);
  79.         break;
  80.         }
  81.     case '3':
  82.         {
  83.         cout<<"Iloczyn to "<<iloczyn(x,y);
  84.         break;
  85.         }
  86.     case '4':
  87.         {
  88.  
  89.         iloraz(x,y);
  90.  
  91.         break;
  92.         }
  93.  
  94.     case '5':
  95.         {
  96.            exit(0);
  97.        }
  98.     default:
  99.         {
  100.             cout<<"\n\n\ Brak opcji w MENU" <<endl;
  101.         }
  102.  
  103.  
  104.  
  105.  
  106.  
  107.     }
  108.     getchar();getchar();
  109.         system("cls");
  110.     }
  111.     return 0;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement