Convert Km to Meter Centimeter or Millimeter in C Language

Convert Km to Meter Centimeter or Millimeter in C Language

Write a program in C Language to Convert Km to Meter Centimeter or Millimeter in C Language.

/*    Convert Km to Meter, Centimeter or Millimeter    */
#include<stdio.h>
int main()
{
	float km;
	char v;
	float ans;

	printf("K.M. : ");
	scanf("%f",&km);
	printf("KM will be changed in (M,s,m) : ");
	fflush(stdin);
	scanf("%c",&v);
	if(v=='M')
	ans=km*1000;
	if(v=='s')
	ans=km*100000;
	if(v=='m')
	ans=km*1000000;
	printf("Answer : %.2f",ans);
	return 0;
}

Leave a Reply

Close Menu