# Find Total Curtains | Tech Mahindra coding question

## Find Total Curtains :-

A Cloth merchant has some pieces of cloth of different lengths. He has an order of curtains of length of 12 feet. He has to find how many curtains can  be made from these pieces. Length of pieces of cloth is recorded in feet.

Note : You are expected to write code in the findTotalCurtains function only which receive the first parameter as the number of items in the array and second parameter as the array itself. You are not required to take the input from the console.

Example

Finding the total curtains from a list of 5 cloth pieces.

Input
input 1 : 5
input 2 : 3 42 60 6 14

Output
9

Explanation
The first parameter 5 is the size of the array. Next is an array of measurements in feet. The total number of curtains is 5 which is calculated as under

3 -> 0
42 -> 3
60 -> 5
6 -> 0
14 -> 1
total = 9

## Find Total Curtains :-

The objective of the code is to find the number of curtains that can be made by the pieces of clothes given . For this we divide all the length of the pieces by 12 (length of curtain) .

C++ Code :-
#include<bits/stdc++.h>
using namespace std;

int findTotalCurtains(int n,int a[])
{
int total=0;
for(int i=0;i<n;i++)
{
// length of one curtains is 12
total+=(a[i]/12);
}
}

// Driver function
int main()
{
int n,start;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
cout<<findTotalCurtains(n,a);
return 0;
}

Output:-
5
3 42 60 6 14
9