Convert Kilometers to Meters by C Program

By | June 16, 2019

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.

Convert Kilometers to Meters by C Program
Convert Kilometers to Meters by C 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;
}

 

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *