here is the problem..
The function floor is one of the functions available in the C math library (floor(x) rounds the decimal number x to the largest integer not greater than x). The function floor can be used to round a number to to a specific decimal place. For example, the statement
y = floor( x*100 + .5)/100;
rounds x to the hundredths position.
Write a program that defines a function called roundtohundreths that rounds a number to the nearest hundredth. For each value read, your program should display the original value (a decimal number) and the number rounded. Your program should have a loop prompting the user to enter a "Y," if a number is to be entered, or a "N" if no new number will be entered.
here is my code so far.. which is not working very well----
#include <stdio.h>
#include <math.h>
int roundtohundreths (int, int);
int main ()
{
int t, b, N, Y;
float x, y;
printf( "Type Y for entering a number ( N to end ): " );
while( ( t = getchar() )!= N ) {
switch ( t ) {
case 'Y': case 'y':
printf( "Enter number: " );
scanf( "%f", &x);
y = ( x * 100 + .5 ) / 100;
printf( "Original value is %.4f\n", y );
printf( "Rounded number is %d\n", roundtohundreths(x, y ) );
}
printf( "Type Y for entering a number ( N to end ): " );
scanf( "%d", &b );
}
return 0;
}
int roundtohundreths (int a, int b )
{
int roundto = a;
a = floor( b * 100 + .5 ) / 100;
return roundto;
}
help would be greatly appreciated!!!!!!!!!