Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
unsigned int RountInteger(unsigned int N)
{
/* Last digit. */
unsigned int lastDigit = -1;
/* Go to the last digit and get it. */
lastDigit = N % 10;
/* Reduce the last digit. */
N /= 10;
/* Case factors. */
if(lastDigit >= 5)
return N+1;
return N;
}
int main(int argc, char* argv[])
{
unsigned int N = 7884;
printf("N = %d\nN Rounded: %d\n", N, RountInteger(N));
N = 7889;
printf("N = %d\nN Rounded: %d\n", N, RountInteger(N));
printf("Hit enter to continue...\n");
getchar();
return 0;
}