Guest User

Untitled

a guest
Feb 9th, 2016
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int wybor,a,b;
  7.  
  8. float dodawanie(int a, int b)
  9. {
  10. return a+b;
  11. }
  12.  
  13. float odejmowanie(int a, int b)
  14. {
  15. return a-b;
  16. }
  17.  
  18. float mnozenie(int a, int b)
  19. {
  20. return a*b;
  21. }
  22.  
  23. float dzielenie(int a, int b)
  24. {
  25. return a/b;
  26. }
  27.  
  28. float potegowanie(int a, int b)
  29. {
  30. return pow(a,b);
  31. }
  32.  
  33.  
  34.  
  35.  
  36. int main()
  37. {
  38. cout<<"Kalkulator v1"<<endl;
  39.  
  40. do
  41. {
  42. cout<<"[1]Dodawanie"<<endl;
  43. cout<<"[2]Odejmowanie"<<endl;
  44. cout<<"[3]Mnozenie"<<endl;
  45. cout<<"[4]Dzielenie"<<endl;
  46. cout<<"[5]Potegowanie"<<endl;
  47. cout<<"[6]Zamknij program"<<endl;
  48.  
  49. cout<<"Co chcesz zrobic?"<<endl;
  50. cin>>wybor;
  51.  
  52. switch(wybor)
  53. {
  54. case 1:
  55. cout<<"Podaj pierwsza liczbe: "<<endl;
  56. cin>>a;
  57. cout<<"Podaj druga liczbe: "<<endl;
  58. cin>>b;
  59. cout<<"Wynik: "<<dodawanie(a,b)<<endl;
  60. break;
  61. case 2:
  62. cout<<"Podaj pierwsza liczbe: "<<endl;
  63. cin>>a;
  64. cout<<"Podaj druga liczbe: "<<endl;
  65. cin>>b;
  66. cout<<"Wynik: "<<odejmowanie(a,b)<<endl;
  67. break;
  68. case 3:
  69. cout<<"Podaj pierwsza liczbe: "<<endl;
  70. cin>>a;
  71. cout<<"Podaj druga liczbe: "<<endl;
  72. cin>>b;
  73. cout<<"Wynik: "<<mnozenie(a,b)<<endl;
  74. break;
  75. case 4:
  76. cout<<"Podaj pierwsza liczbe: "<<endl;
  77. cin>>a;
  78. cout<<"Podaj druga liczbe: "<<endl;
  79. cin>>b;
  80. cout<<"Wynik: "<<dzielenie(a,b)<<endl;
  81. break;
  82. case 5:
  83. cout<<"Podaj liczbe, ktora chcesz spotegowac: "<<endl;
  84. cin>>a;
  85. cout<<"Podaj potege, do ktorej chcesz podniesc liczbe: "<<endl;
  86. cin>>b;
  87. cout<<"Wynik: "<<potegowanie(a,b)<<endl;
  88.  
  89.  
  90. break;
  91.  
  92. default:
  93. cout<<"Nieprawidlowy wybor!!!"<<endl;
  94.  
  95.  
  96. }
  97.  
  98. } while(wybor=!5);
  99.  
  100.  
  101. system("PAUSE");
  102. return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment