Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Progrm to find the squar root of a number in c, cpp,cplus plus

Program to find the square root of a number in c and CPP,c plus plus

In this tutorial, we will try to learn the followings;

  1. How to draw the flow chart of the square root of a number?
  2. How to find the square root of a number in C++?
  3. How to find the square root of a number in C?

How to draw the flow chart of the square root of a number?

Progrm to find the squar root of a number in c, cpp,cplus plus

Figure: Program to find the square root of a number in c, CPPC++.

How to find the square root of a number in C++?

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
  float NO, answer_of_GivenNO;
  cout <<"Enter number to find its squareroot: ";
  cin >> NO;
  answer_of_GivenNO = pow(NO, 0.5);
  cout<<"Squreroor of "<<NO<<" is: " << answer_of_GivenNO << endl;
}

Output:

square root output

Figure: square root output.

How to find the square root of a number in C?

#include <stdio.h>
#include <math.h>
int main()
{
    double no, root_of_no;
    printf("Enter number to find its root: ");
    scanf("%lf", &no);
    root_of_no = sqrt(no);
    printf("Square root of %.2lf = %.2lf", no, root_of_no);
}

Output:

square root output

Figure: square root output.