/* 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;
}
#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;
}
Thanks for the convert km to m formulae in C
ReplyDeletekm to m
GOOD JOB ADMIN, But it is Conditional Programs, so it could be under "Conditional Programs" as you have separated on site.
ReplyDeleteWhy is it written fflush(stdin) and what is the function of fflush?
ReplyDeleteIt's a function which allows you to flush [clear] the input buffer. You might use this function if you are thinking that there might be some data in input buffer which can create problems for you while taking user inputs from stdin.
Deletefflush function is used to flush the input buffer.
DeleteWill you please explain this program in detailed steps,
DeleteThe C library function int fflush(FILE *stream) flushes the output buffer of a stream.
ReplyDeleteFollowing is the declaration for fflush() function.
int fflush(FILE *stream)
c language for new user, chapter wise complete theory and programm
ReplyDeletenice article for beginners.thank you.
ReplyDeletewelookups C++
javacodegeeks
cormefos-hi1982 Michelle King https://wakelet.com/wake/LJFMndarRq1_PpUFilw17
ReplyDeletedespdifnela
UneotarYbeji Angela Jiang Driver Easy Pro
ReplyDeleteWinRar
Visit
wheelnoughpulvi