In this HackerRank Boxes through a Tunnel in the C programming problem, we need to make a c program in which we have given the height of the tunnel 41 feet and the width can be assumed to be infinite. A box can be carried through the tunnel only if its height is strictly less than the tunnel's height. Find the volume of each box that can be successfully transported to the other end of the tunnel. Note: Boxes cannot be rotated.


HackerRank Boxes through a Tunnel in c problem solution

HackerRank Boxes through a Tunnel in c problem solution

 #include <stdio.h>
struct Box
{
    int length, width, height;
};

int volume(struct Box box)
{
    return box.length*box.width*box.height;
}

int lower(struct Box box, int maxHeight)
{
    return box.height < maxHeight;
}

int main()
{
   int n;
   scanf("%d", &n);
   struct Box boxes[100];
   for (int i = 0; i < n; i++)
      scanf("%d%d%d", &boxes[i].length, &boxes[i].width, &boxes[i].height);
   for (int i = 0; i < n; i++)
      if (lower(boxes[i], 41))
         printf("%d\n", volume(boxes[i]));
   return 0;
}