অষ্টকোণ (octagon) হলো আট বাহু বিশিষ্ট একটি বহুভুজ। এর ক্ষেত্রফল বের করার সূত্র:
Area = ((a² × 2) / tan(22.5°)) = 2a²(1 + √2)
কোড লজিক: উপরের সূত্র ব্যবহার করে ক্ষেত্রফল বের করা হয়। sqrt() ফাংশন দিয়ে ২-এর বর্গমূল বের করা হয়। ফলাফল ফ্লোটিং পয়েন্ট ভ্যালু হিসেবে সংরক্ষণ হয়।
উদাহরণ
#include <stdio.h>
#include <math.h>
int main() {
int a = 7;
float area;
float multiplier = 6.18;
printf("Program to find area of octagon \n");
printf("The side of the octagon is %d \n", a);
area = ((2 * a * a) * (1 + sqrt(2)));
printf("The area of Octagon is %f \n", area);
return 0;
}
আউটপুট
Program to find area of octagon The side of the octagon is 7 The area of Octagon is 236.592926