Classes/csci218/Labs/Lab2/circleArea.c

22 lines
798 B
C

//circleArea.c
//Garrett Haldrup
//Sept 2 2024
//This program will caclulate the area of a circle given a radius given by user
#include <stdio.h>
int main(){
// display the purpose of the program
printf("This program will calculate the area of a cricle\n");
// define the variable: radius and area, both with datatype float
float radius, area;
const float PI = 3.14159;
// input: receive radius from the user (keyboard)
printf("Please enter the radius of the circle: ");
scanf("%f", &radius);
//printf("The radius of the circle is: %f\n", radius);
// process: Calculate area by using the formula of a circle
area = PI * radius * radius;
// output: display the `area` on the screen
printf("The area of the circle with radius %.2f is: %.2f\n", radius, area);
return 0;
}