Question :
Given an array of integers representing measurements in inches, write a program to
calculate the total of measurements in feet. Ignore the measurements those are less than a
feet (e.g. 10)
Note:
You are expected to write code in the find TotalFeet function only which will 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 input from the console.
Example
Finding the total measurements in feet from a list of 5 numbers
Input
input1: 5
input2: 18 11 27 12 14
Output
5
Answers
Answered by
2
Answer:
itz a question from isc conputer science...x...java
Answered by
10
Answer:
#include <iostream>
#include <bits/stdc++.h>
int findTotalFeet(int input1,int input2[])
{
int temp;
int cal = 0;
for(int i = 0 ; i < input1 ; i++)
{
if(input2[i] > 10)
{
temp = (input2[i])/12;
cal = cal + temp;
}
}
return cal;
}
int main() {
int n,temp;
int arr[n];
std::cin>>n;
for(int i = 0; i < n ; i++)
{
std::cin>>arr[i];
}
std::cout<<findTotalFeet( n, arr);
}
Similar questions