# Functions

1.One foot equals 12 inches. Design a function named
feetTolnches that accepts a number of feet as an argument, and returns the number of inches in that many feet. Use the function in a program that prompts the user to enter a number of feet and then displays the number of inches in that many feet.
2.Rainfall Statistics
Design a program that lets the user enter the total rainfall for each of 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts

#### George

• Jul 29th, 2014

In Haskell (please excuse syntax highlighting; they dont have it for this language):

```Code-- feetToInches.hs
module Main where

feetToInches :: Num a => a -> a
feetToInches = (*12)

main :: IO ()
main = do
feet <- putStr "Enter number of feet to convert: ""Enter rainfall for " ++ (snd . (!!n)) months ++ ": ") >> getLine) [0..11]
let values = map (read :: String -> Float) inputs
let f g = snd . g \$ zip values [0..]

mapM_ putStrLn ["Total rainfall: ""Mean rainfall: ""Month with highest rainfall: " ++ snd (months !! (f maximum)),
"Month with lowest rainfall: " ++ snd (months !! (f minimum))]
where months = zip [0..] ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"]   ```

#### Sunil shenoy

• May 16th, 2016

```Code#include<iostream>
using namespace std;
float ft_to_inch(float ft)
{
return ft*12;
}
main()
{
float f,i;
cout<<"Enter a Feet value:"<<endl;
cin>>f;
i=ft_to_inch(f);
cout<<"result in Inches: "<<i<<endl;
}```