Skip to content
Snippets Groups Projects
next.c 623 B
Newer Older
Bruce Cowan's avatar
Bruce Cowan committed
#include <stdio.h>
#include <stdlib.h>
#include <tgmath.h>

int
main (int argc, char **argv)
{
    float start;
    float end;

    if (argc != 3)
	{
		printf ("Please input the lower value: ");
		scanf ("%f", &start);

		printf ("Please input the upper value: ");
		scanf ("%f", &end);
	}
	else
	{
		sscanf (argv[1], "%f", &start);
		sscanf (argv[2], "%f", &end);
	}

    float current = start;
    size_t count = 0;

    do
    {
        current = nextafter (current, end);
        count++;
    } while (current != end);

    printf ("There are %zu float numbers between %G and %G\n", count, start, end);
    return 0;
}