C++ Program to Find Square Root of a Number


In this Example, You will learn How to Find Square Root of a Number in C++ by using predefined library Function ( Math.h).


ans = sqrt(num);

4 = sqrt(16);


Example: Find Square Root of a Number in C++

Run it Now
#include<iostream>
#include<math.h>
using namespace std;

int main() {

    float num, ans;
    cout << "Enter a Number :";
    cin >> num;

    ans = sqrt(num);
    cout << "\nSquare root of " << num << " is :" << ans;

    return 0;
}

Output:

Enter a Number :16
Square root of 16 is :4