C Program to Convert Centimeters to Meter

Centimeter to Meter conversion C program

In this article, we are going to discuss how to convert centimeters to meters in the c Program. So let’s start!

C Program to Convert Centimeters to Meter

For example-

Input-

So first step is we are going to take user input in it so that we take input as the length in centimeters which is 22.3

logic-

Before starting the program we have to know the formula to convert centimeters to meters and the formula is :

Meter = (cm)/ 100

Output-

According to our input, we get output as
Enter the length in cm:22.3
The value in meters is 0.223000

So let’s start to implement this formula in our program. before starting our program we see two examples in the first example we simply use the formula and in the second example, by using a user-defined function.

C Program to Convert Centimeter to Meter Example

//C program to convert the value from centimeter to meter.
#include<stdio.h>
int main(){
float cm, m ;
printf(“Enter the length in cm :”);
scanf(“%f”, &cm);
m = cm /100;
printf(“The value in meters is %f”, m);
return 0;
}

Output
Enter the length in cm:22.3
The value in meters is 0.223000

  • Step 1: First we take two float-type variables one is to take input from the user in the form of cm and another for formula which is meter.
  • Step 2: Now as the next step we use scanf() to store the value of a variable.
  • Step 3: After this, we simply use the formula. We can see this from the above example.
  • Step 4: After the above steps we simply use printf() to get our output.

Example 2 –

// C program to convert the value from centimeter to meter.

#include<stdio.h>
float meter(float centimeter){
return centimeter/100;
}
int main(){
float centimeter, c;
printf(“Enter the value in centimeter”);
scanf(“%f”, &centimeter);
c =meter(centimeter);
printf(“The value in meter is %f”, c);
return 0;
}

Output
Enter the value in centimeters 22.3
The value in meters is 0.223000

In this way, we simply understand how to convert meters to centimeters. I hope these things are clear to you. So for now keep learning and keep exploring!