ภาพรวมปัญหา
ในปัญหานี้ เราได้รับค่า 2 ค่า คือ ฐาน (base) และ สูง (height) ของรูปสี่เหลี่ยมขนาน งานของเราคือสร้างโปรแกรมหาพื้นที่ของรูปสี่เหลี่ยมขนานใน C++
ข้อมูลพื้นฐาน
รูปสี่เหลี่ยมขนาน (Parallelogram) คือ รูปปิด 4 ด้าน ที่มีด้านตรงข้ามเท่ากันและขนานกัน

ตัวอย่าง
Input
B = 20, H = 15
Output
300
คำอธิบาย
พื้นที่รูปสี่เหลี่ยมขนาน = ฐาน × สูง = 20 × 15 = 300
แนวทางแก้ปัญหา
ใช้สูตรเรขาคณิตพื้นฐาน: Area = base × height
ตัวอย่างโปรแกรม
#include <iostream>
using namespace std;
float calcParallelogramArea(float B, float H) {
return (B * H);
}
int main() {
float B = 20, H = 15;
cout << "The area of parallelogram with base " << B << " and height " << H << " is " << calcParallelogramArea(B, H);
return 0;
}
Output
The area of parallelogram with base 20 and height 15 is 300