C++ Program to Find Diagonal of a Rectangle
Given two positive integers i.e, the length and breadth of the rectangle, the task is to find the length of the Diagonal of a Rectangle.
Example:
Input: length=4 breadth=3
output: The Diagonal is 5
The diagonal of a rectangle is sqrt (a*a+ b*b)
C++
#include <bits/stdc++.h>
using namespace std;
double findDiagonal( double a, double b)
{
return sqrt (a * a + b * b);
}
int main()
{
double a = 4, b = 3;
cout << "The Diagonal is " << findDiagonal(a, b);
return 0;
}
|
Time Complexity: O(1)
Auxiliary Space: O(1)
Last Updated :
15 Sep, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...