/* Round.c */

#include <stdio.h>

double round (double d)
{
    return ((double) ( (int) ((d >= 0.0) ? (d + 0.5) : (d - 0.5) )));
}

int main (void)
{
    double dValue;

    printf("\nDemonstrate rounding: values may be positive, negative or zero...\n");
    do {
        printf("\nInput a double value (=0 to terminate): ");
        scanf("%f", &dValue);
        printf("dValue = %f  %f\n", dValue, round(dValue));
    } while (dValue != 0.0);

    printf("\nPress a key...");
    getchar();
    return 0;
}
