ক্ষেত্রফল হলো দ্বিমাত্রিক সমতলে একটি আকৃতি কত জায়গা ঘেরেছে তার পরিমাপ। বৃত্তের ক্ষেত্রফল বের করতে ত্রিজ্যা (r) বা ব্যাস (d = 2r) দরকার।
সূত্র: πr² বা (πd²)/4
উদাহরণ কোড (ত্রিজ্যা দিয়ে)
#include <stdio.h>
int main(void) {
float pie = 3.14;
int radius = 6;
printf("The radius of the circle is %d \n", radius);
float area = (float)(pie * radius * radius);
printf("The area of the given circle is %f", area);
return 0;
}
আউটপুট
The radius of the circle is 6 The area of the given circle is 113.040001
উদাহরণ কোড (math.h-এর pow() ব্যবহার করে)
#include <stdio.h>
#include <math.h>
int main(void) {
float pie = 3.14;
int radius = 6;
printf("The radius of the circle is %d \n", radius);
float area = (float)(pie * pow(radius, 2));
printf("The area of the given circle is %f", area);
return 0;
}
আউটপুট
The radius of the circle is 6 The area of the given circle is 113.040001
উদাহরণ কোড (ব্যাস দিয়ে)
#include <stdio.h>
int main(void) {
float pie = 3.14;
int diameter = 12;
printf("The Diameter of the circle is %d \n", diameter);
float area = (float)((pie * diameter * diameter) / 4);
printf("The area of the given circle is %f", area);
return 0;
}
আউটপুট
The Diameter of the circle is 12 The area of the given circle is 113.040001