Calculate the continued fraction using the function indicators I'm developing programs on Golang. But now you have to study at the university and have the following task.




  Calculate the continued fraction using the function indicators. The
  number of fractional elements must be specified from the keyboard. 1 +
  1 / (1 + 1 / (1 + 1 / (1 + 1 / ....))). The number of elements of the
  fraction must be at least 5. Consider three cases, for example, 5, 7
  and 10.

Enter the number of elements of the continued fraction: 6 
Solution - 1.61538



Please check my code.



#include &lt;iostream&gt;
using namespace std;
int main(){

    int n;
    double t;
    t=2;
    bool exit;


    while (exit != true) {
        printf("To exit the programs, type 0\n");
        cout &lt;&lt; "Enter the number of continued fractions: " &lt;&lt; endl;
        cin &gt;&gt; n;

        if (n == 0) {
            exit = true;
        } else {
            if (n &lt; 5) {
                printf("The number of elements of a fraction must be at least 5");
                cin.get();
            } else {
                for (int a = 1; a &lt; n; a++) {
                    t = 1 / t + 1;
                }
                cout &lt;&lt; "Decision - " &lt;&lt; t &lt;&lt; endl;
            }
        }
    }
    printf("Exiting the program");
    return 0;
}
Don't use using namespace std 
Prefer prefix over postfix
return 0 is not needed at the end of main
Prefer using \n over std::endl
Don't use printf in C++ code
As Reinderien already mentioned the exit variable is not needed. I.e.

for (;;) {
        // [...]
        if (n == 0) {
            break;
        }
        // [...]


will be sufficient.