how to create area of square using double | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to create area of square using double

23rd Jul 2016, 9:47 AM
A.Adil Basha
A.Adil Basha - avatar
3 Answers
+ 2
Area of a square is side^2. Create a double variable, we'll call it side and another one we'll call area. Then you can either times it by itself, or use Math.pow. Example, double side = 5. double area = side * side or double area = Math.pow(side, 2).
23rd Jul 2016, 12:48 PM
James
James - avatar
+ 1
you can use any of the two ways either return side^2 or return math.pow(side,2) where "side" is a double variable
23rd Jul 2016, 3:13 PM
Hardik Patel
Hardik Patel - avatar
0
Thank You James and Hardik.. it's working , double area = Math.pow(side,2) thank you James✌✌
23rd Jul 2016, 1:42 PM
A.Adil Basha
A.Adil Basha - avatar