Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How can I write sqrt in this emulator?

+1 vote
asked Oct 21, 2021 by ANDREA GUADALUPE RODRIGUEZ CHAVEZ (130 points)
I'm trying to get the hipotenuse of a triangle in my program C++, but I can write sqrt for the equation and I don´t know how to write in another way.

1 Answer

0 votes
answered Oct 22, 2021 by Peter Minarik (86,040 points)
edited Oct 22, 2021 by Peter Minarik

sqrt() works just fine:

#include <math.h>
#include <stdio.h>

double FindHypotenuse(double a, double b)
{
    return sqrt(a * a + b * b);
}

int main()
{
    printf("The Hypotenuse for a triangle with sides 3, 4, ? is: %f\n", FindHypotenuse(3, 4));
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...