C Program to Convert Inches to Centimetres

« C Tutorial C Examples »

In this tutorial, we will learn about how to create a program in C that will ask from user to enter length (in Inch) to convert and print its equivalent length into centimetre. But before going through the program given below, let's first understand about the relation between inch and centimetre.

Inch and Centimetre Relation

The relation between inch and centimetre is either written as:

1 centimetre = 0.3937 inches


1 inch = 2.54 centimetre

Note - The spelling, centimetre is used as International spelling, whereas centimeter is used as American spelling

Note - A centimetre is equal to one hundredth of a meter.

Centimetre is represented or abbreviated as (cm), whereas inches is represented as (" or in). Therefore, we can write:

1" = 2.54 cm

Now let's move on to the program.

Inch to Centimetre in C

The question is, write a program in C that converts length from inch to centimetre. The answer to this question is given below:

// Inche to Centimetre Conversion Program in C

int main()
    float inch, cm;
    printf("Enter length in Inch: ");
    scanf("%f", &inch);
    cm = inch * 2.54;
    printf("Equivalent length in Centimetres = %0.2f", cm);
    return 0;

As the above program was written under Code::Blocks IDE, therefore after successful build and run, here is the snapshot of sample run:

c program convert inches to centimeters

Now supply any length in inch say 12 and press ENTER key to see the same length in centimetre. Here is the second snapshot of the sample run:

convert inches to centimeters c program

Here are some of the main steps used in above program:

« C Tutorial C Examples »