RUN


Square Root of Number program in C++

# Important Points:

  • Square root in C++ can be calculated using sqrt() function defined in <math.h> header file.
  • sqrt() function takes a number as an argument and returns the square root of that number.

 

Example:

Given number: 1296

Square root: 36

# Algorithm

  1. Create a variable number and root.
  2. Enter the number whose cube root is to be calculated.
  3. Get the cube root using function sqrt().

Code:

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

int main(){
  float number, root;
  cout << "Enter number whose root is to be found: ";
  cin >> number;
  root = sqrt(number);
  cout << "Square root of " << number << " is " << root;
  return 0;
}

 

Report Error/ Suggestion

Related Posts:

[yuzo_views]



Interview Questions



CopyRight © 2020

CopyRight © 2020