Sunday, November 2, 2014

Filled Under: , ,

Program to find area of circle using power function in command line argument.

Share
area of circle

Code Box
--------------------------------------

/*Program to find area of circle using power function in command line argument */

class areacf
{
public static void main(String x[])
{

float a,r;

r=Float.parseFloat(x[0]);

System.out.print("\nRadius of circle is = "+r);

a=3.14f*(float)(Math.pow(r,2));

/* you can also write it as

a=3.14f*(Math.pow(r,2));
But in this case Math.pow(r,2) returns a double value not a
float that cause an error.
*/

System.out.print("\nAread of circle is = "+a);

}
}

0 comments:

Post a Comment