Breaking

Saturday 30 September 2017

Area of a Circle

                              Area of a Circle



The program must accept the diameter of the circle as a command line argument and print the area of the circle rounding it up to 2 decimal places.
Example Input/Output 1:
Input:
14
Output:
154.00
Example Input/Output 2:
Input:
14.42
Output:
163.38
Example Input/Output 3:
Input:
1
Output:
0.79
Code:


#include<stdio.h>
#include<stdlib.h>
int main(int argc, char *argv[])
{
    double r=atof(argv[1])/2;
    printf("%.2f",3.142857*r*r);

}

Please do comment If u have any Queries!

No comments:

Post a Comment

Like