Sunday, 29 September 2013

decimal of numbers in c

decimal of numbers in c

I just asked a question but couldn't get what I want, and couldn't edited
and reply as it is too long. My question is the same and it is the link to
that question.how to keep decimals in 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;
}

No comments:

Post a Comment