在幾何學中,菱形是四個邊長相同的四邊形。菱形與形狀菱形相似。如果菱形的對角線成直角,那麼它就變成正方形。
菱形的性質是-
下圖是菱形
給定對角線,假設d1 和d2 的任務是找出菱形的面積和周長,其中面積是形狀所佔據的空間,週長是其邊界將覆蓋的空間
要計算長方體的面積和周長,有一個公式-
Input-: d1=6 and d2=12 Output-: The perimeter of rhombus with given diagonals are :26 The area of rhombus with given diagonals are :36
Start Step 1 -> declare function to calculate perimeter of rhombus int perimeter(int d1, int d2) Declare variable long long int perimeter Set perimeter = 2 * sqrt(pow(d1, 2) + pow(d2, 2)) Print perimeter Step 2 -> Declare function to calculate area of rhombus int area(int d1, int d2) Declare long long int area Set area = (d1 * d2) / 2 Print area Step 3 -> In main() Declare variable int d1 = 6, d2 = 12 Call perimeter(d1, d2) Call area(d1, d2) Stop
#include <iostream> #include <math.h> using namespace std; // program to calculate perimeter of rhombus int perimeter(int d1, int d2){ long long int perimeter; perimeter = 2 * sqrt(pow(d1, 2) + pow(d2, 2)); cout<< "The perimeter of rhombus with given diagonals are :"<<perimeter; } //program to calculate area of rhombus int area(int d1, int d2){ long long int area; area = (d1 * d2) / 2; cout<<"</p><p>The area of rhombus with given diagonals are :"<< area; } int main(){ int d1 = 6, d2 = 12; perimeter(d1, d2); area(d1, d2); return 0; }
The perimeter of rhombus with given diagonals are :26 The area of rhombus with given diagonals are :36#
以上是計算菱形的面積和周長的程序,已知對角線是什麼?在C++中,什麼是菱形?的詳細內容。更多資訊請關注PHP中文網其他相關文章!