Answers 839
F
5: int number1 = 10,
6: number2 = 5;
7: int x, y, z;
8:
9: x = product( number1, number2 );
10: y = divide_em( number1, number2 );
11: z = divide_em( number1, 0 );
12:
13: printf( “\nnumber1 is %d and number2 is %d”, number1, number2 );
14: printf( “\nnumber1 * number2 is %d”, x );
15: printf( “\nnumber1 / number2 is %d”, y );
16: printf( “\nnumber1 / 0 is %d”, z );
17:
18: return 0;
19: }
- The code is as follows:
/ Averages five float values entered by the user. /
#include <stdio.h>
float v, w, x, y, z, answer;
float average(float a, float b, float c, float d, float e);
int main( void )
{
puts(“Enter five numbers:”);
scanf(“%f%f%f%f%f”, &v, &w, &x, &y, &z);
answer = average(v, w, x, y, z);
printf(“The average is %f.\n”, answer);
return 0;
}
float average( float a, float b, float c, float d, float e)
{
return ((a+b+c+d+e)/5);
}
- The following is the answer using type intvariables. It can run only with values
less than or equal to 9. To use values larger than 9 , you need to change the values
to type long.
/ this is a program with a recursive function /
#include <stdio.h>
int three_powered( int power );
49 448201x-APP F 8/13/02 11:22 AM Page 839