fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. float number;
  8. float result;
  9. char answer;
  10.  
  11. cout << "Please input a number." << endl;
  12. cin >> number;
  13. do {
  14. if (number > 0) {
  15. result = sqrt(number);
  16. cout << "Your result is: " << result << endl;
  17. }
  18. else {
  19. cout << "The previous number input was " << number << endl;
  20. }
  21. cout << "Would you like to continue?" << endl;
  22. cin >> answer;
  23. } while(answer == "Y");
  24.  
  25. return 0;
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
9
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:23:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  } while(answer == "Y")
                    ^~~
prog.cpp:25:2: error: expected ‘;’ before ‘return’
  return 0;
  ^~~~~~
stdout
Standard output is empty