Ads by ProfitSence
Close

C++ sqrt

Last Updated on Wednesday 5th Oct 2022

square root in c++

  • sqrt function c++.

The sqrt() function in C++ returns the square root of a number.

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

int main() {
  cout << "Square root of 36 = ";
  cout << sqrt(36);

  return 0;
}

// Output: Square root of 36 = 6

			
	

square root c++

sqrt() Syntax

The syntax of the sqrt() function is:

			
					sqrt(double num);

			
	

c++ square root

  • sqrt() Parameters
  • sqrt() function takes the num parameter.
  • num - A double, float, long double, or any integral type value.

Return Value

The sqrt() function returns the square root of the given argument.

square root function c++

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

int main() {
  double num = 13.13;
  double result = sqrt(num);
  cout << "Square root of " << num << " is " << result;
  return 0;
}

			
	
			
					Square root of 13.13 is 3.62353

			
	

c++ sqrt

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

int main() {
    double x;
    cout << "Enter a number : ";
    cin >> x;

    double result = sqrt(x);
    cout << "sqrt(" << x << ") : " << result << endl;
}

			
	
			
					Enter a number : 5
sqrt(5) : 2.23607

Enter a number : 16
sqrt(16) : 4