Я просто задал вопрос, но не смог получить то, что хочу, и не мог отредактировать и ответить, поскольку он слишком длинный. Мой вопрос тот же, и это ссылка на этот вопрос. how to keep decimals in cдесятичное число чисел в 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;
}
Почему я не могу объяснить свою проблему? Хорошо, но проверьте, если a = 1, тогда код должен работать правильно? Но это не так! Пожалуйста, не рассматривайте else, если часть, когда a = 2, просто проверьте a = 1. –
@BerkDemir, какую ошибку вы получаете? –
@BerkDemir Вы должны быть более конкретными в отношении своей проблемы, например, ввода, вывода и ожидаемого результата. –