Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7. int age;
  8. char wybor;
  9. do {
  10. system("cls");
  11. /*cout << "What is your age? \n";
  12. cin >> age;
  13. if (age > 5) {
  14. cout << "Your age is more than 5. \n";
  15. }
  16. else if (age == 0) {
  17. cout << "You are 5 years old. \n";
  18. }
  19. else {
  20. cout << "Your age is less than 5. \n";
  21. }
  22. cout << "Your age is: " << age << endl; */
  23. /*
  24. int a, b;
  25. cout << "Put your first number \n";
  26. cin >> a;
  27. cout << "Put your second number \n";
  28. cin >> b;
  29. */
  30. /*cout << "Sum of your numbers is: " << a + b <<endl; */
  31.  
  32. /*while (a > b) {
  33. cout << a << " is bigger than " << b << endl;
  34. break;
  35. }
  36. while (b > a) {
  37. cout << b << " is bigger than " << a << endl;
  38. break;
  39. }
  40. while (a==b) {
  41. cout << a << " and " << b << " are even numbers \n";
  42. }
  43. */
  44.  
  45. /*
  46. if (a > b) {
  47. cout << a << " is bigger than " << b << endl;
  48. }
  49. else if (a < b) {
  50. cout << b << " is bigger than " << a << endl;
  51. }
  52. else {
  53. cout << a << " and " << b << " are even numbers \n";
  54. }
  55. */
  56. double a, b, c, delta;
  57. cout << "Put a: ";
  58. cin >> a;
  59. cout << "Put b: ";
  60. cin >> b;
  61. cout << "Put c: ";
  62. cin >> c;
  63. delta = b * b - (4 * a * c);
  64.  
  65. if (delta > 0) {
  66. cout << "x1 is: " << (-b + sqrt(delta)) / (2 * a)<<endl;
  67. cout << "x2 is: " << (-b - sqrt(delta)) / (2 * a) << endl;
  68. }
  69. else if (delta == 0) {
  70. cout << "x0 is: " << (-b) / (2 * a) << endl;
  71. }
  72. else {
  73. cout << "There are no possible solutions \n";
  74. }
  75. cout << "If you want to try again write 'y'. \n";
  76. cin >> wybor;
  77. } while (wybor == 'Y' || wybor == 'y');
  78. return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement