Write a C program to enter length in centimeter and convert it into meter and kilometer - Basic C Program



 

Write a C program to enter length in centimeter and convert it into meter and kilometer


Objective:

Write a C program to input length in centimeter and convert it to meter and kilometer. How to convert length from centimeter to meter and kilometer in C programming. Length conversion program in C from centimeter to meter and centimeter to kilometer.


Example


Input
Enter length in centimeter = 1000
Output

Length in meter = 10 m
Length in kilometer = 0.01 km



Length conversion formula
Centimeter to meter and centimeter to kilometer conversion formula is given by -
1m = 100 cm

1km = 100000 cm

%.2f is used to print the fractional value up to two decimal places. You can also use %f to print by default up to 6 decimal places.



Solution Code:

//C program to convert centimeter into meter and kilometer by CodexRitik #include <stdio.h> int main() { float cm, meter, km; /* Input length in centimeter from user */ printf("Enter length in centimeter: "); scanf("%f", &cm); /* Convert centimeter into meter and kilometer */ meter = cm / 100.0; km = cm / 100000.0; printf("Length in Meter = %.2f m \n", meter); printf("Length in Kilometer = %.2f km", km); return 0; }



Note:

This Code is Verified by CodexRitik.If any error occurs then Comment correct code Below in comment box.

Disclaimer:-

The above hole problem solution is generated by the CodexRitik . if any of the query regarding this post or website fill the following contact form Thank You.

Write a C program to enter length in centimeter and convert it into meter and kilometer - Basic C Program Write a C program to enter length in centimeter and convert it into meter and kilometer - Basic C Program Reviewed by CodexRitik on January 03, 2021 Rating: 5

No comments:

Powered by Blogger.