Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

C hypot Function

by suresh

The C hypot function is a Math Function, used to calculate the Trigonometric Hypotenuse Value of given two sides. The syntax of the hypot in C Programming is

double hypot(double number);

Hypothenuse = square root of the sum of squares of two sides (specified arguments).

C hypot Function Example

The math hypot Function allows you to find the Hypotenuse Value of a given side. In this program, We are going to find the hypotenuse and display the output.

/* Example for HYPOT in C Programming */

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

int main()
{ 
    printf("\n The Hypotenuse Value of 10 & 0  = %.4f ", hypot(10, 0));
    printf("\n The Hypotenuse Value of 0 & -5  = %.4f ", hypot(0, -5));
    
    printf("\n The Hypotenuse Value of 5 & -2  = %.4f ", hypot(5, -2));
    printf("\n The Hypotenuse Value of -2 & 10 = %.4f ", hypot(-2, 10));
    
    printf("\n The Hypotenuse Value of 10 & 12 = %.4f ", hypot(10, 12));
    printf("\n The Hypotenuse Value of 5 & 20  = %.4f ", hypot(5, 20));
    
    return 0;
}
C hypot Function 1

C hypot Example 2

In this C Programming example, we are allowing the user to enter their two sides of a triangle. Next, we used the hypot function to find the hypotenuse of a user given side.

/* Example for HYPOT in C Programming */

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

int main()
{
    int side1, side2;
    float hValue;

    printf(" Please Enter the First and Second Side :  ");
    scanf("%d%d", &side1, &side2);
  
    hValue = hypot(side1, side2);
  
    printf("\n The Hypotenuse Value of %d & %d = %.4f ", side1, side2, hValue);
  
    return 0;
}
C hypot Function 2

Placed Under: C Programming

  • C Comments
  • C Escape Sequence
  • C Programming Operators
  • C Arithmetic Operators
  • C Assignment Operators
  • C Bitwise Operators
  • C Conditional Operator
  • C Increment & Decrement Optr
  • C Logical Operators
  • C Relational Operators
  • C Sizeof Operator
  • C If Statement
  • C IF ELSE Statement
  • C Else If Statement
  • C Nested If
  • C Break Statement
  • C Continue Statement
  • C Goto Statement
  • C Switch Case
  • C For Loop
  • C While Loop
  • C Do While Loop
  • C Arrays
  • C Two Dimensional Array
  • C Multi Dimensional Array
  • C String
  • C Structures
  • C Nested Structures
  • C Array of Structures
  • C Structures and Functions
  • C Union
  • C Structure & Union differences
  • C Pointers
  • C Pass Pointers to Functions
  • C GETS
  • C fgets Function
  • C fgetc
  • C fputs function
  • C fputc
  • C Functions
  • C Types of Functions
  • C Pass Array to Functions
  • Call By Value & Call By Reference
  • C Recursion
  • C Program Examples

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy