Language C
Description It converts a length in millimetres into meters, centimeters and millimetres.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    int centimeters, length_in_millimetres, meters, millimetres;
    printf ("Enter the value of length in millimetres: ");
    scanf ("%d", &length_in_millimetres);
    (void) getchar ();
    millimetres=length_in_millimetres%1000;
    centimeters=(millimetres-length_in_millimetres)/1000;
    meters=(centimeters-centimeters%100)/100;
    centimeters=centimeters%100;
    printf ("Value of centimeters: %d\n", centimeters);
    printf ("Value of meters: %d\n", meters);
    printf ("Value of millimetres: %d\n", millimetres);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}