Language C
Description It tests the decimals of three floating numbers if they are the same.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main (void)
{
    float a, b, c, decimals_of_a, decimals_of_b;
    float decimals_of_c;
    printf ("Enter the value of a: ");
    scanf ("%f", &a);
    (void) getchar ();
    printf ("Enter the value of b: ");
    scanf ("%f", &b);
    (void) getchar ();
    printf ("Enter the value of c: ");
    scanf ("%f", &c);
    (void) getchar ();
    decimals_of_a=a-floor(a);
    decimals_of_b=b-floor(b);
    decimals_of_c=c-floor(c);
    if(decimals_of_a==decimals_of_b&&decimals_of_b==decimals_of_c)
        printf ("Their decimals are the same\n");
    else
        printf ("Their decimals are different\n");
    printf ("Value of decimals of a: %g\n", decimals_of_a);
    printf ("Value of decimals of b: %g\n", decimals_of_b);
    printf ("Value of decimals of c: %g\n", decimals_of_c);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}