Monday, April 11, 2016

Program to convert and print distance meter and centimeter.

Q.The distance between two cities (in kms) is input through the keyboard. Write a program to convert and print this distance in meters, and centimeters.
Program:
#include <stddio.h>
#include <conio.h>
void main()
{
float km,m,c;
printf(“enter the distance in km;”);
scanf(“%f”,&km);
m=km*1000;
c=m*1000;
printf(“\nThe distance in meter is=%f”,m);
printf(“\nThe distance in centimeter is=%f”,c);
getch();
}
Output:
enter the distance in km:2
The distance in meter is=2000

The distance in centimeter is=2000000

No comments:

Post a Comment