0

Please help me out. Develop a simple application using function to calculate the area of the following. *Square *Rectangle *

15th Jun 2017, 12:22 PM
Ahaa mark
Ahaa mark - avatar
3 Réponses
+ 3
As you doesn't answer to specify wich language you're expected, I will describe you in pseudo language how do it, so you can practice and implement it by yourself ;) For calculating area of Square or Rectangle, there's only one tiny difference: Square are just particularly Rectangle, where both width and height are same... so you can factorize you code, so the square area function will just have to call the rectangle area one, giving same attribute for the second dimension. Mathematical formula for rectangle/square area is simply width*height ^^ function square_area(side) { return rect_area(side,side); } function rect_area(width,height) { return width*height; } Maybe you have to integrate them in a simple application for asking user to input dimension, and then display the result... but i/o (input.output) handling is too specifically linked to the language you're expected for guide you without knowing :P Anyway, your question seems to be truncated, and probably you have other shapes area function to implement? If this can help, formula for circle area is: PI*(radius^2), which could be also write PI*radius*radius... Pi constant is available in any language, often in a math library ^^
15th Jun 2017, 6:07 PM
visph
visph - avatar
+ 1
What language?
15th Jun 2017, 12:31 PM
Limitless
Limitless - avatar
+ 1
Brah, What programming language are you using?
15th Jun 2017, 3:23 PM
Limitless
Limitless - avatar