Pages

Sunday, July 8, 2018

Convert centimeter to inch scale

Problem: Write a C program to read a length in centimeter scale and convert it in the inch scale.

Solution:                           
                                                   Formula:

                                       inch = centimeter / 2.54

Code:


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <stdio.h>

int main()
{
    float centi, inch;
    printf("Enter the length in centimeter: ");
    scanf("%f", &centi);

    inch = centi / 2.54;

    printf("The length in inch scale is : %0.2f\n", inch);

    return 0;
}

Task: Now, write a C program to to convert inch to centimeter scale.

No comments:

Post a Comment