C++ program to find square root?

Follow
  • Follow publicly
  • Follow privately
  • Unfollow
code to compute a c++ program that will accept input from a user and find the square root
Best Answer
/* sqrt example */
#include <stdio.h>
#include <math.h>

int main ()
{
double param, result;
param = 1024.0;
result = sqrt (param);
printf ("sqrt(%lf) = %lf\n", param, result );
return 0;
}
Output:

sqrt(1024.000000) = 32.000000

I hope this helps
  • Rate
  • Comment

Other Answers (2)

Rated Highest
  • Rated Highest
  • Oldest
  • Newest
  • sinkablehail1978 answered 5 years ago
    there is a c++ library function called sqrt(<input value>) that you can use for this.
    • Rate
    • Comment
  • Alex V answered 5 years ago
    include <cmath>
    #include <iostream>
    int main()
    {
    int a;
    std::cout << "enter a: ";
    std::cin >> a;

    std::cout << std::sqrt(double(a)) << std::endl;
    }
    • Rate
    • Comment
  • Sign In 

    to add your answer

Who is following this question?

    %
    BEST ANSWERS
    Member Since:
    Points: Points: Level
    Total Answers:
    Points this week:
    Follow
     
    Unfollow
     
    Block
     
    Unblock