I l @ ve RuBoard |
Devise a function min(x,y) that returns the smaller of two double values, and test the function with a simple driver.
Devise a function chline(ch,i,j) that prints the requested character in columns i through j . Test it in a simple driver.
Write a function that takes three arguments: a character and two integers. The character is to be printed. The first integer specifies the number of times that the character is to be printed on a line, and the second integer specifies the number of lines that are to be printed. Write a program that makes use of this function.
The harmonic mean of two numbers is obtained by taking the inverses of the two numbers , averaging them, and taking the inverse of the result. Write a function that takes two double arguments and returns the harmonic mean of the two numbers.
Write a function that replaces the contents of two variables with two new values: the sum and the difference of the original contents.
Write a program that reads characters from the standard input to end-of-file. For each character, have the program report whether it is a letter. If it is a letter, also report its numerical location in the alphabet. For example, c and C would each be letter 3. Incorporate a function that takes a character as an argument and returns the numerical location if the character is a letter and that returns -1 otherwise .
In Chapter 6, "C Control Statements: Looping," (refer to Listing 6.18) we wrote a power() function that returned the result of raising a type double number to a positive integer value. Improve the function so that it correctly handles negative powers. Also, build into the function that 0 to any power is 0 and that any number to the 0 power is 1. Use a loop. Test the function in a program.
Redo Exercise 7, but this time use a recursive function.
Generalize the to_binary() function of Listing 9.9 so that it takes a second argument in the range 2 “10. It then prints the number that is its first argument to the number base given by the second argument.
I l @ ve RuBoard |