C Online Compiler
Example: Circle Measurement in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Circle Measurement #include <stdio.h> #include <math.h> // Required for M_PI or custom PI definition #ifndef M_PI #define M_PI 3.14159265358979323846 #endif void calculateCircle() { float radius, area, circumference; printf("\n--- Circle Calculator ---\n"); printf("Enter the radius of the circle: "); scanf("%f", &radius); if (radius <= 0) { printf("Error: Radius must be a positive value.\n"); return; } area = M_PI * radius * radius; // or pow(radius, 2) circumference = 2 * M_PI * radius; printf("Area of the circle: %.2f\n", area); printf("Circumference of the circle: %.2f\n", circumference); }
Output
Clear
ADVERTISEMENTS