I have two small programs dealing with writing functions. I'm not not skilled at writing functions. for the second assignment, what type of recursive function can i use? Can someone give me an example of both types of functions that I have to write.

Exercise 1:

Write a function called celsToFahr that takes in as a parameter a Celsius temperature (type double) and returns the corresponding Fahrenheit temperature (also type double). Recall that the matehmatical formula for converting temperatures between these scales is:

F = 9 / 5 * C + 32

To test this function, write a main() routine that asks the user for a celsius temperature, and then prints out a chart that illustrates the celsius to fahrenheit conversions for 10 celsius temperatures starting at the entered value and incrementing the celsius temperature by 1 each time. See the sample output for clarification.

Sample run 1: (user input underlined)

Enter a celsius temperature: 40

Cels. Fahr.

------------------------------------------------------

40 104

41 105.8

42 107.6

43 109.4

44 111.2

45 113

46 114.8

47 116.6

48 118.4

49 120.2

Sample run 2: (user input underlined)

Enter a celsius temperature: 12.54

Cels. Fahr.

------------------------------------------------------

12.54 54.572

13.54 56.372

14.54 58.172

15.54 59.972

16.54 61.772

17.54 63.572

18.54 65.372

19.54 67.172

20.54 68.972

21.54 70.772

--------------------------------------------------------------------------------

Exercise 2

Write a recursive function called GCD() that takes in two integer parameters and returns the greatest common divisor. The recursive routine should be based on the following recursive definition of GCD (Djikstra's algorithm):

GCD(m,n) is m, if m equals n.

GCD(m,n) is GCD(m - n, n) if m is greater than n.

GCD(m,n) is GCD(m, n - m) otherwise.

Test your function by writing a main() routine that asks the user to input two positive integers and then calls the GCD method and prints the result.

Sample run:

Input first number : 45

Input second number : 10

GCD(45, 10) = 5