Saturday, September 30, 2017

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

Solution:
#include <stdio.h>
#include <stdlib.h>
void main(int c,char *b[])
{
    float a = atof(b[1])/2;
    printf("%.2f",3.142857*a*a);
}
Share: