Tuesday, 29 August 2017

C Program to Convert Km to Meter, Centimeter or Millimeter

/*    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;
}

No comments:

Post a Comment