What is cuboid?
Cuboid คือทรง 3 มิติที่มี 6 ผิวเป็นรูปสี่เหลี่ยมผืนผ้า หมายถึงมีความยาว ความกว้าง ความสูงไม่เท่ากัน ต่างจาก Cube ที่ทุกด้านเท่ากัน
คุณสมบัติ −
- 6 ผิว
- 12 ขอบ
- 8 จุดยอด
ภาพทรงสี่เหลี่ยมมุมฉาก

ปัญหา
ให้ความยาว ความกว้าง ความสูง หาพื้นที่ผิวมากและปริมาตร พื้นที่ผิวคือพื้นที่ผิวทั้งหมด ปริมาตรคือปริมาณที่บรรจุได้
สูตร −
Surface Area = 2(l*w + w*h + l*h)
Volume = L * W * H
ตัวอย่าง
Input-: L=3 H=2 W=3 Output-: Volume of cuboid is: 18 Total Surface Area of cuboid is: 42
อัลกอริทึม
Start Step 1 -> declare function to find volume of cuboid double volume(double l, double h, double w) return (l*h*w) Step 2 -> declare function to find area of cuboid double surface_area(double l, double h, double w) return (2 * l * w + 2 * w * h + 2 * l * h) Step 3 -> In main() Declare variable double l=3, h=2 and w=3 Print volume(l,h,w) Print surface_area(l, h ,w) Stop
ตัวอย่าง
#include <bits/stdc++.h> using namespace std; //function for volume of cuboid double volume(double l, double h, double w){ return (l * h * w); } //function for total surface area of cuboid double surface_area(double l, double h, double w){ return (2 * l * w + 2 * w * h + 2 * l * h); } int main(){ double l = 3; double h = 2; double w = 3; cout << "Volume of cuboid is: " <<volume(l, h, w) << endl; cout << "Total Surface Area of cuboid is: "<< surface_area(l, h, w); return 0; }ผลลัพธ์
Volume of cuboid is: 18 Total Surface Area of cuboid is: 42