Convert Kilometers to Meters
This programming exercise is a basic C program. It simply converts km into meters. The user of the program will provide input and press Enter during execution of the program.
Here is a description of different C language statements used in this program.
Kilometers to meters conversion C program
- Basic C language program template
- This program uses Pre processor Directives like “include” to include required header files.
- This C program uses Variable declaration statements
- It uses printf() function to display message to user for entering kilometers as input.
- This program uses assignment statement to calculate formula of converting kilometers into meters.
- printf() function to show the result in meters.
#include<stdio.h>
int main()
{
float km, meters;
printf(“Enter Kilometrs to be converted:”);
scanf(“%f”, &km);
meters = km * 1000;
printf(“Meters are=%f”,meters);
return 0;
}