November 30, 2022 |3.5K Views

    C++ Program to Find Diagonal of a Rectangle

      Share  1 Like
    Description
    Discussion

    In this video, we will write a C++ program to find the diagonal of a rectangle.

    Formula:
    Diagonal = length*length + breadth*breadth

    Example:

    Input: 
    length = 4 & breadth = 3

    Output: The Diagonal = 5

    Dry run:

    We know that the diagonal of a rectangle is sqrt (a*a+ b*b)
    So given that here length = 4 and Breadth = 3
    => diagonal of a rectangle is sqrt (4*4+ 3*3)
    => sqrt(16+9)
    => Sqrt(25)
    => So the diagonal of a rectangle is 5.

    Here in this video, we will calculate the diagonal of a rectangle using a simple formula.

    C++ Program to Find Diagonal of a Rectangle: https://www.geeksforgeeks.org/cpp-program-to-find-diagonal-of-a-rectangle/