/* Terry D. Johnson 091400 This program demonstrates the granularity problem by adding a small float to a large float one million times. */ #include int main(void) { int i; float big, small, sum; /* Asks the user to input a small number and a large number as floats. */ printf("Input a big number, please.\n"); scanf("%f", &big); printf("Now input a small number.\n"); printf("I'm going to add the small number to the big number a million times!\n"); scanf("%f", &small); /* Adds the small number to the big number a million times. */ sum = big; for (i = 1; i <= 1000000; i++) { sum = sum + small; } /* Prints the result onto the screen. */ printf("The big number plus a million small numbers is: "); printf("%f", sum); printf("\n...isn't it? D'oh!\n"); return(0); }