Problem: C program for " The distance between two cities in KM is input through the keyboard. Write a program to convert and print this distance in meter, feet, inches and centimeters."
Formula used:
Meter = Kilometer x 1000.
Centimeter = Kilometer x 100000
Inch = Kilometer x 39370.0780
Feet = Kilometer x 3280.8399
C program:
// Program by Shyam Kanth#include<stdio.h>int main(){int km, m, cm;float feet, inch;printf("Enter the distance in kilometers : ");scanf("%d",&km);m = km*1000;cm = km*100000;inch = km*39370.0787;feet = km*3280.8399;printf("The distance is : \n");printf("%d meters \n%d centimeters \n%.2f inches \n%.2f foots.",m,cm,inch,feet);return 0;}
Codes used:
- #include <stdio.h> : Header file for input output
- int : Integer data type
- float : Decimal data type
- km,m,cm,feet,inch : Variable used
- printf : Function for displaying message
- scanf : Function for taking input
Do comment, if any doubt
Know about me : Shyam Kanth
No comments:
Post a Comment