
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Program for Volume and Surface Area of Cuboid in C++
What is cuboid?
Cuboid is a three-dimensional object with six faces of rectangle shape which means it has sides of different length and breadth. The difference between a cube and cuboid is that a cube has equal length, height and breadth whereas in cuboids these three are not same
Properties of cuboid are −
- six faces
- 12 edges
- 8 vertices
Given below is the figure of cube
Problem
Given with the length, width and volume, the task is to find the total surface area and volume of a cuboid where surface area is the space occupied by the faces and volume is the space that a shape can contain.
To calculate surface area and volume of a cuboid there is a formula
Surface Area = 2(|*w + w * h + |*h )
Volume = L* W * H
Example
Input-: L=3 H=2 W=3 Output-: Volume of cuboid is: 18 Total Surface Area of cuboid is: 42
Algorithm
Start Step 1 -> declare function to find volume of cuboid double volume(double l, double h, double w) return (l*h*w) Step 2 -> declare function to find area of cuboid double surface_area(double l, double h, double w) return (2 * l * w + 2 * w * h + 2 * l * h) Step 3 -> In main() Declare variable double l=3, h=2 and w=3 Print volume(l,h,w) Print surface_area(l, h ,w) Stop
Example
#include <bits/stdc++.h> using namespace std; //function for volume of cuboid double volume(double l, double h, double w){ return (l * h * w); } //function for total surface area of cuboid double surface_area(double l, double h, double w){ return (2 * l * w + 2 * w * h + 2 * l * h); } int main(){ double l = 3; double h = 2; double w = 3; cout << "Volume of cuboid is: " <<volume(l, h, w) << endl; cout << "Total Surface Area of cuboid is: "<< surface_area(l, h, w); return 0; }
Output
Volume of cuboid is: 18 Total Surface Area of cuboid is: 42
- Related Articles
- Java Program to Find the Surface area and Volume of Cuboid
- Swift Program to Find the Surface area and Volume of Cuboid
- Haskell Program to Find the Surface area and Volume of Cuboid
- Kotlin Program to Find the Surface Area and Volume of Cuboid
- How to find the Surface area and Volume of Cuboid in Golang?
- Program for Volume and Surface Area of Cube in C++
- Program for Volume and Surface area of Frustum of Cone in C++
- Golang program to Calculate the Volume, Diagonal and Area of a Cuboid?
- What is total surface area of cuboid?
- What is the lateral surface area of a cuboid?
- Surface Area and Volume of Hexagonal Prism in C programming
- Program for Surface area of Dodecahedron in C++
- Program for Surface Area of Octahedron in C++
- Find maximum volume of a cuboid from the given perimeter and area in C++
- Find the lateral surface area and total surface area of a cuboid of length $80\ cm$, breadth $40\ cm$ and height $20\ cm$.

Advertisements