C Program to Convert Kilometer to Meter

C program to convert kilometer to meter: 

Formula: 1 km = 1000 meters


C Proogram to convert kilometers to meter:
#include<stdio.h>
void main()
{
float km, meters;
printf("Enter the distance in kilometers = ");
scanf("%f",&km);
meters = km * 1000;
printf("The Kilometers in meters = %f",meters);
}
Output:
Enter the distance in kilometers = 10
The Kilometers in meters = 10000.000000
Explanation:
  • Two variables km, meters are declared of type float.
  • The value of km is taken from the keyboard given by the user.
  • And formula meters = km * 1000 is applied.
  • And last Prints the value of “meters".
See also:
Share:

Ads

Search This Blog

  • ()
Powered by Blogger.

Strings in C With Syntax, C String Program with output

Strings in C :  Strings can be defined as the one-dimensional array of characters terminated by a null ('\0'). The difference betwee...

Blog Archive