5. distance conversion:
Convert a distance from miles to kilometers .there are 5280
feets per mile,12 inches per foot .2.54 centimeters per
inch and 100000centimeters per kilometer
Answer Posted / yogesh bansal
#include <stdio.h>
#define FEETS 5280
#define INCH 12
#define CENTIMETER 2.54
#define CMPERKM 100000
int main()
{
unsigned int miles=0;
unsigned feets;
unsigned inches;
double centimeter;
double KM;
printf("please enter the distance in miles\n");
scanf("%u",&miles);
feets = miles * FEETS;
printf("the distance in feets %u\n",feets);
inches = feets * INCH;
printf("the distance in inches %u\n",inches);
centimeter = inches * CENTIMETER;
printf("the distance in centimeter %fd\n",centimeter);
KM = centimeter/CMPERKM;
printf("the distance in KM %fd\n",KM);
return 0;
}
| Is This Answer Correct ? | 3 Yes | 4 No |
Post New Answer View All Answers
Explain 'bus error'?
What is the difference between array and pointer in c?
Tell me when is a void pointer used?
Implement bit Array in C.
What are pragmas and what are they good for?
What are the 5 elements of structure?
What is uint8 in c?
What is the difference between scanf and fscanf?
Describe newline escape sequence with a sample program?
What is a structure and why it is used?
Explain how do you determine a file’s attributes?
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
How can I write a function that takes a format string and a variable number of arguments?
Why we use int main and void main?
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?