Showing posts with label area of circle. Show all posts
Showing posts with label area of circle. Show all posts

Sunday, November 2, 2014

, ,

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

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);

}
}

Publisher: Brijmohan Lal Sahu - 3:20 AM
, , ,

Program to find area of circle using command line argument.



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

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

class areac
{
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*r*r;

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



}
}

Publisher: Brijmohan Lal Sahu - 3:15 AM