Sat 09 February 2019, in category Procedures and Functions
A function is a block of code consisting of a group of statements that usually return a value. Additionally, logic can be encapsulated within a function to allow easier testing and consistency in the application. Here are various examples that show how to calculate the area of rectangle.
private int calculateArea(int length, int width)
{
return length * width;
}
private int calculateArea(int length, int width)
{
return length * width;
}
def calculateArea(length, width):
return length * width
function calculateArea(length, width)
{
return length * width;
}
func calculateArea(length int, width int){
return length * width
}