R_Code-12.r ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 20 Mar 2026
- License — MIT
Problem Statement ​
Problem Statement
Write a custom function named calculate_area that takes two parameters: length and width. The width parameter should have a default value of 5. The function should print the product of the two parameters. Finally, call your function passing only the value 12 for the length.
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
r
# Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 20 Mar 2026
# Repo: https://github.com/notamitgamer/bsc
# License: MIT
# Write a custom function named calculate_area that takes
# two parameters: length and width. The width parameter should have
# a default value of 5. The function should print the product of the
# two parameters. Finally, call your function passing only the value 12 for the length.
calculate_area <- function(length, width = 5) {
print(length * width)
}
calculate_area(12)1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14