Given length l, width b and height h of a cuboid. Return an array containing the total surface area and volume of the cuboid.
Examples:
Input: l = 1, b = 2, h = 3
Output: [22, 6]
Explanation: Surface Area = 2*(l*b + b*h + l*h) = 2*(2*3 + 3*1 + 1*2) = 22 and Volume = l*b*h = 1 * 2 * 3 = 6Input: l = 2, b = 3, h = 5
Output: [62, 30]
Explanation: Surface Area = 2(l*b + b*h + l*h) = 2 *(3*5 + 5*2 + 2*3) = 62 and Volume = l*b*h = 2 * 3 * 5 = 30
Try It Yourself
Cuboid has 6 rectangle-shaped faces. Each face meets another face at 90 degrees. Three sides of the cuboid meet at the same vertex. We can find Total Surface Area and Volume by using below formulas:
Total Surface Area = 2 * (l*w + w*h + l*h)
Volume= l*w*h

#include <bits/stdc++.h>
using namespace std;
vector<int> find(int l, int b, int h)
{
// formula for Total Surface Area: 2 * (lb + bh + hl)
int area = 2 * (l * h + b * h + l * b);
// formula for Volume: l * b * h
int volume = (l * b * h);
vector<int> res;
res.push_back(area);
res.push_back(volume);
return res;
}
int main()
{
int l = 2;
int b = 3;
int h = 4;
vector<int> ans = find(l, b, h);
cout << ans[0] << " " << ans[1] << endl;
return 0;
}
public class Main {
public static int[] find(int l, int b, int h)
{
// formula for Total Surface Area: 2 * (lb + bh +
// hl)
int area = 2 * (l * h + b * h + l * b);
// formula for Volume: l * b * h
int volume = (l * b * h);
int[] res = new int[2];
res[0] = area;
res[1] = volume;
return res;
}
public static void main(String[] args)
{
int l = 2;
int b = 3;
int h = 4;
int[] ans = find(l, b, h);
System.out.println(ans[0] + " " + ans[1]);
}
}
def find(l, b, h):
# formula for Total Surface Area: 2 * (lb + bh + hl)
area = 2 * (l * h + b * h + l * b)
# formula for Volume: l * b * h
volume = (l * b * h)
res = []
res.append(area)
res.append(volume)
return res
if __name__ == "__main__":
l = 2
b = 3
h = 4
ans = find(l, b, h)
print(f"{ans[0]} {ans[1]}")
using System;
public class Program {
public static int[] find(int l, int b, int h)
{
// formula for Total Surface Area: 2 * (lb + bh +
// hl)
int area = 2 * (l * h + b * h + l * b);
// formula for Volume: l * b * h
int volume = (l * b * h);
int[] res = new int[2];
res[0] = area;
res[1] = volume;
return res;
}
public static void Main()
{
int l = 2;
int b = 3;
int h = 4;
int[] ans = find(l, b, h);
Console.WriteLine(ans[0] + " " + ans[1]);
}
}
function find(l, b, h)
{
// formula for Total Surface Area: 2 * (lb + bh + hl)
let area = 2 * (l * h + b * h + l * b);
// formula for Volume: l * b * h
let volume = (l * b * h);
let res = [];
res.push(area);
res.push(volume);
return res;
}
let l = 2;
let b = 3;
let h = 4;
let ans = find(l, b, h);
console.log(ans[0] + " " + ans[1]);
Output
52 24