Write a program to find the perimeter of a circle


Default
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Write a program to find the perimeter of circle
// Ex: r:3 -> Perimeter: 18.85

 
#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 perimeter of circle
    double pi = 22/7.0;
    double perimeter = 2*pi*r;
    printf("\nPerimeter of circle: %lf",perimeter);
    getch();
}

No comments:

Post a Comment