I want to make it so that after using the calculator, I can enter exit into the console and close, thereby, the console. This code is not compiled, it is written that there is an error in the last brace, while is required, but I do not understand how to enter it

#include <iostream> #include <stdio.h> #include <cstdlib> #include <locale> #include <math.h> using namespace std; int main() { setlocale(LC_ALL, "RUSSIAN"); string o; do { cout << "Выполните действие" << endl; float x, y, z; char q; cin >> x; cin >> q; cin >> y; { switch (q) { case '^': z = pow(x, y); case '+': (z = x + y); case '-': (z = x - y); case '/': (z = x / y); case '*': (z = x * y); } } cout << (z) << endl; cin >> o; if (o == "exit") exit(0); else { exit(0); } } } 
  • four
    In C ++ there is no do {...} construction, there is only a do {...} while (); construction do {...} while (); - andy.37
  • one
    if it’s too difficult to do-while just put a while (true) {} - nick_n_a
  • Thanks, it really helped, but only after performing the action, my console closes by pressing any button, how can I do this so that I can enter numbers to infinity, for example 5 + 5 = 10 and on the next line I can re-enter any number and that the program also performs the action (5 + 5 = 10 10 + 20 = 30) And then, when I think of it, I enter the exit and the program closes - ZolbergN

1 answer 1

Well carry out check in while - type

 do { ... cin >> o; } while (o != "exit"); exit(0); // Если это в функции main(), то можно просто выйти из нее 

Like that...