พื้นที่คือปริมาณที่แสดงถึงขอบเขตของตัวเลขในสองมิติ พื้นที่ของวงกลมคือพื้นที่ที่วงกลมปกคลุมในระนาบสองมิติ
ในการหาพื้นที่ของวงกลม ต้องใช้รัศมี[r] หรือเส้นผ่านศูนย์กลาง[d](รัศมี 2*)
สูตรที่ใช้คำนวณพื้นที่คือ (π*r 2 ) หรือ {(π*d 2 )/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>
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