Guest User

Untitled

a guest
May 26th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. Enter the number of elements of the continued fraction: 6
  2. Solution - 1.61538
  3.  
  4. #include <iostream>
  5. using namespace std;
  6. int main(){
  7.  
  8. int n;
  9. double t;
  10. t=2;
  11. bool exit;
  12.  
  13.  
  14. while (exit != true) {
  15. printf("To exit the programs, type 0n");
  16. cout << "Enter the number of continued fractions: " << endl;
  17. cin >> n;
  18.  
  19. if (n == 0) {
  20. exit = true;
  21. } else {
  22. if (n < 5) {
  23. printf("The number of elements of a fraction must be at least 5");
  24. cin.get();
  25. } else {
  26. for (int a = 1; a < n; a++) {
  27. t = 1 / t + 1;
  28. }
  29. cout << "Decision - " << t << endl;
  30. }
  31. }
  32. }
  33. printf("Exiting the program");
  34. return 0;
  35. }
Add Comment
Please, Sign In to add comment