我只是问了一个问题,但无法得到我想要的东西,并且由于太长而无法编辑和回复。我的问题是一样的,它是该问题的链接。如何在c中保留小数
#include<stdio.h>
int main()
{
float b,c,;
int a,kk;
printf("Welcome to the unit conversion program\n");
printf("This program can convert the measurements of;\n");
printf("1-Length\n");
printf("2-Mass\n");
printf("Please select the number that corresponds to the measurement you want to convert in:\n");
scanf("%d",&a);
if (a==1){
printf("Your number will be converted from inches to centimeters.\n");
printf("Please enter the length.\n");
scanf("%f",&b);
c=b*2.54;
printf("%f inch is %f cm.",b,c);
scanf("%d",kk); \. to avoid to shut the cmd windows .\
}
else if (a==2){
printf("Your number will be converted from pounds (lbs) to kilograms");
printf("Please enter the mass.\n");
scanf("%d",&b);
c=b*0.45359237;
printf("%d lbs is %d kgs.",b,c);
}
return 0;
}