- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# C program to find amount of volume passed through a tunnel

Suppose there is a tunnel whose height is 41 and width is very large. We also have a list of boxes with length, width and height. A box can pass through the tunnel if its height is exactly less than tunnel height. We shall have to find amount of volume that are passed through the tunnel. The volume is length * width * height. So we have a number N, an 2D array with N rows and three columns.

So, if the input is like N = 4 boxes = [[9,5,20],[3,7,15],[8,15,41],[6,3,42]], then the output will be 900 and 315 we can pass first two boxes, the volumes are 9 * 5 * 20 = 900 and 3 * 7 * 15 = 315. The height of other boxes are not supported.

To solve this, we will follow these steps −

Define Box data type with length, width and height

Define a function volume(), this will take box,

return box.length * box.width * box.height

Define a function lower(), this will take box,

return true if box.height < 41 otherwise false

From the main method, do the following:,

for initialize i := 0, when i < N, update (increase i by 1), do:

if lower(boxes[i]) is true, then:

display volume(boxes[i])

## Example

Let us see the following implementation to get better understanding −

#include <stdio.h> #define N 4 struct Box{ int length, width, height; }; int volume(struct Box box){ return box.length*box.width*box.height; } int lower(struct Box box){ return box.height < 41; } int solve(struct Box boxes[]){ for (int i = 0; i < N; i++) if (lower(boxes[i])) printf("%d\n", volume(boxes[i])); } int main(){ struct Box boxes[N] = {{9,5,20},{3,7,15},{8,15,41},{6,3,42}}; solve(boxes); }

## Input

4, {{9,5,20},{3,7,15},{8,15,41},{6,3,42}}

## Output

900 315

- Related Questions & Answers
- Program to find the formatted amount of cents of given amount in Python
- Program to find the Area and Volume of Icosahedron in C++
- Program to calculate volume of Ellipsoid in C++
- Program for volume of Pyramid in C++
- Program to find equation of a plane passing through 3 points in C++
- How to find Volume and Surface Area of a Sphere using C#?
- C++ program to find maximum possible amount of allowance after playing the game
- Java Program to Find the Surface area and Volume of Cuboid
- Program to calculate area and volume of a Tetrahedron
- Find a specified amount of records in MongoDB?
- C++ Program to find out the maximum amount of score that can be decreased from a graph
- Program to find line passing through 2 Points in C++
- Java Program to round a double passed to BigDecimal
- Program to Find Out the Amount of Rain to be Caught between the Valleys in C++
- What Does a VPN Tunnel Do?