Uses defined constants for PI - C Preprocessor

C examples for Preprocessor:Preprocessor Operators

Description

Uses defined constants for PI

Demo Code

#include <stdio.h>
#define PI 3.14159/*from   w w  w . j  ava2s .com*/
int main(void)
{
    float area, circum, radius;
    
    printf("What is the radius of your pizza?\n");
    scanf("%f", &radius);
    area = PI * radius * radius;
    circum = 2.0 * PI *radius;
    printf("circumference = %1.2f, area = %1.2f\n", circum, area);
    return 0;
}

Result


Related Tutorials