จัตุรมุขคือพีระมิดที่มีฐานเป็นรูปสามเหลี่ยม กล่าวคือ มีฐานเป็นรูปสามเหลี่ยมและแต่ละด้านมีรูปสามเหลี่ยม สามเหลี่ยมทั้งสามมาบรรจบกันเป็นจุด ดังในรูป

รหัสลอจิก − รหัสในการหาพื้นที่และปริมาตรของจัตุรมุขใช้ห้องสมุดคณิตศาสตร์เพื่อค้นหาสแควร์และสแควร์รูทของตัวเลขโดยใช้วิธี sqrt และ pow สำหรับการคำนวณพื้นที่เราใช้จุดลอยตัวและค่าของนิพจน์ "((sqrt(3)*a*a))" จะได้รับ ตัวแปรอื่นรับค่าปริมาตรของจัตุรมุขที่ประเมินโดยใช้นิพจน์ “(a*a*a/(6*(sqrt(2)))))” .
ตัวอย่าง
#include <stdio.h>
#include <math.h>
int main() {
int a = 5;
float area, volume;
printf("Program to find area and volume of Tetrahedron\n");
printf("The side of Tetrahedron is %d \n", a);
area = (sqrt(3)*(a * a));
printf("The area of Tetrahedron is %f \n", area);
volume = (pow(a, 3) / (6 * sqrt(2)));
printf("The volume of Tetrahedron is %f \n", volume);
return 0;
} ผลลัพธ์
Program to find area and volume of Tetrahedron The side of Tetrahedron is 5 The area of Tetrahedron is 43.301270 The volume of Tetrahedron is 14.731391