Program to Convert Centimeter to Feet and Inches in C


Given with the length into centimeter as an input, the task is to convert the given length into feet and inches

We can use length conversion formula for this −

1 feet = 30.48 cm
1 inche = 2.54 cm

Example

Input-: centimetre = 100
Output -: Length in meter = 3m
   Length in Kilometer = 0.003km

Algorithm

Start
Step 1 -> Declare function to perform conversion
   double convert(int centimeter)
      set double inch = 0.3937 * centimetre
      set double feet = 0.0328 * centimetre
      print inch and feet
Step 2 -> In main()
   Declare and set int centimetre=20
   Call convert(centimetre)
Stop

Example

#include <stdio.h>
// Function to perform conversion
double convert(int centimeter){
   double inch = 0.3937 * centimeter;
   double feet = 0.0328 * centimeter;
   printf ("Inches is: %.2f 
", inch);    printf ("Feet is: %.2f", feet);    return 0; } // Driver Code int main() {    int centimeter = 20;    convert(centimeter);    return 0; }

Output

Inches is: 7.87
Feet is: 0.66

Updated on: 23-Sep-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements