Find Total Feet Program Tech Mahindra, The “Find Total Feet” program is a common coding question asked in Tech Mahindra hiring tests. It checks how well a student can use logic with numbers and conditions. In this task, you get a list of values in inches, and you must convert only the valid parts into feet. This challenge is simple but smart, and it helps recruiters test problem-solving skills in real coding time.
Problem Statement as Given in the Exam:
You are given a list of numbers where each number shows a length in inches. Your task is to find how many full Feet can be made from these values.

Only full feet count, so if a value is less than 12 inches, it should be ignored. The total feet from all valid values must be added and shown as the final answer. This test checks your ability to apply basic math and logic in a real coding task.
How the Input Is Given to You
In this program, the input starts with a single number that tells how many values are in the list. After that, you will receive those numbers, each showing a length in inches. All these numbers come in one line, separated by spaces. You have to read them and check how many full feet can be made from them.
What Output You Need to Print
Your output must be a single number the total count of full feet from the input values. You must ignore any value that is less than 12 inches, as it does not make one full foot. Just add all valid feet and print the final total as your answer.
Step-by-Step Logic to Solve the Program
This section explains the exact steps to solve the program using clear and easy logic.
- Start by reading the total number of values in the input.
- Take all the values and store them in a list or array.
- Make a variable called totalFeet and set it to 0.
- Go through each number in the list one by one.
- If a number is 12 or more, divide it by 12 using integer division.
- Add the result to your totalFeet variable.
- If a number is less than 12, skip it.
- After the loop ends, print the value of totalFeet as the final answer.
This simple logic helps you solve the program without confusion. It is clean, easy to understand, and gives the correct result every time.
C Code Solution
Here is a clean and simple C program to solve the Find Total Feet problem. The code reads the input, checks each value, and prints the total number of full feet. Helpful comments are added for better understanding.
include
// Function to calculate total feet from inches
int findTotalFeet(int n, int arr[]) {
int totalFeet = 0;
// Loop through each number in the array
for (int i = 0; i < n; i++) {
// Only count if value is 12 or more
if (arr[i] >= 12) {
totalFeet += arr[i] / 12; // Integer division to get full feet
}
}
return totalFeet;
}
int main() {
int n;
// Read the number of values
scanf("%d", &n);
int arr[n];
// Read each value (in inches)
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
// Print the total feet result
printf("%d", findTotalFeet(n, arr));
return 0;
}
This C code is easy to follow, even for beginners. It uses a simple loop and integer division to solve the problem correctly. For Tech Mahindra coding rounds, this solution is fast, accurate, and fully acceptable.
Java Code Solution with Clear Comments
Below is a simple Java program that solves the “Find Total Feet” question. The code includes clear comments so beginners can understand every step easily.
import java.util.*;
public class Main {
// Method to calculate total feet from inches
static int findTotalFeet(int n, int[] arr) {
int totalFeet = 0;
for (int i = 0; i < n; i++) { // Check if the value is at least 12 inches if (arr[i] >= 12) {
// Add only full feet using integer division
totalFeet += arr[i] / 12;
}
}
return totalFeet;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Read the number of elements
int n = sc.nextInt();
int[] arr = new int[n];
// Read each value in inches
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
// Call the method and print the result
System.out.println(findTotalFeet(n, arr));
}
}
This Java code follows a clear and logical structure. It reads input, checks each value, calculates full feet only, and gives the correct output. Beginners can easily use this code for Tech Mahindra tests and coding interviews.
Python Code Solution
This Python program solves the Find Total Feet challenge in a very simple way. It reads a list of numbers in inches, checks if they are 12 or more, and then adds the total number of full feet. The code is clean and beginner-friendly.
Function to calculate total feet from a list of inches
def find_total_feet(n, arr):
total_feet = 0
# Loop through each value in the array
for value in arr:
if value >= 12:
# Add only full feet using integer division
total_feet += value // 12
return total_feet
Read total number of values
n = int(input())
Read the list of values in inches
arr = list(map(int, input().split()))
Print the total number of full feet
print(find_total_feet(n, arr))
This Python solution is short, fast, and easy to understand. It uses basic concepts like loops, conditions, and integer division. This type of question is common in Tech Mahindra’s coding rounds, and writing a clear solution like this can give you a good score quickly.
Time and Space Complexity of the Program
The time complexity of this program is O(n) because the code goes through each input number only one time. No matter how big the list is, it checks each value just once to calculate the total feet.
The space complexity is O(n) because we store all the input values in an array. If there are n numbers in the input, the program needs space to keep those n numbers in memory.
This makes the program fast and efficient. It works well even if you have a large number of values, and it uses only a small amount of memory.
Common Mistakes to Avoid in This Program
Many beginners make small mistakes in this program that can lead to wrong output or test failure.

- Forgetting to Use Integer Division: Many beginners use normal division, which gives decimal values. But to count full feet, you must use integer division only.
- Not Checking If the Value Is 12 or More: Some users add all values, even the ones below 12 inches. Always skip values that are less than one full foot.
- Wrong Input Format: If the input is not read properly for example, not using a loop to take all numbers the program will not work correctly.
- Using Float or Double Instead of Integer: There’s no need for decimal numbers. Stick to integers to keep the code simple and error-free.
- Printing Extra Messages: Only the final result (the total feet) should be printed. Adding extra text can cause wrong output in coding tests.
Avoiding these mistakes will help you write clean and correct code. Paying attention to small things like conditions and loops can make a big difference in your final result.
Common FAQs About Find Total Feet Program Tech Mahindra
Here are the most asked questions about the Find Total Feet Program in Tech Mahindra coding tests, explained in simple and clear words.
What is the main goal of the Find Total Feet program?
The main goal is to count how many full feet can be formed from a list of values given in inches. Values less than 12 inches are not counted.
Which programming languages can I use to solve this?
You can use any language like C, Java, or Python as long as your code reads input, applies logic correctly, and gives the right output.
Will I lose marks if I print extra text with the answer?
Yes, in coding tests, you should print only the final number. Avoid adding messages like “Result is” or “Output”.
Why is integer division important in this program?
Because you need full feet only. Integer division helps you remove any extra inches automatically.
Can this question appear in Tech Mahindra interviews too?
Yes, it’s common in both online coding rounds and technical interviews to test your logic and basic math handling.
Conclusion
The “Find Total Feet” program has more strengths than weaknesses. It is simple, fast, and perfect for building your coding basics. While it may not be useful in real-world projects, it is a smart way to test your logic and condition-handling skills. If you focus on clear input and the right logic, this program becomes a great tool for Tech Mahindra preparation and beginner coding practice. Avoiding small mistakes can help you write the correct solution every time.