Write a program to find the area of circle

// Write a program to find the area of circle
// Ex: r:3 -> Area: 28.28

 
#include
int main(){
    double r;
    printf("Enter the radius of circle:");
    scanf("%lf",&r);
    while(r<=0){
        printf("Radius can't be negative or zero\n");
        printf("Enter the radius of circle:");
        scanf("%lf",&r);        
    }
    
    // calculating area of circle
    double pi = 22/7.0;
    double area = pi*r*r;
    printf("\nArea of circle: %lf",area);
    getch();
}

No comments:

Post a Comment