DEV Community

Analyze_
Analyze_

Posted on

Cpp Square Root Calculator

I like making calculators so I made one for square root. This uses the cmath package

Link

#include <cmath>
#include <iostream>
using namespace std;

int main() {
  string session = "y";

  while (session == "y") {
    int num = 0;
    cout << "What would you like to find the quare root of?\n";
    cin >> num;
    cout << sqrt(num) << "\nWould you like to continue session [y/n]?\n";
    cin >> session;
    cout << "\x1B[2J\x1B[H";
  } // end of session
  cout << "\x1B[2J\x1B[H";
  cout << "Ended session\n";
  return 1;
} // end of code
Enter fullscreen mode Exit fullscreen mode

Top comments (0)