complete assignment01
This commit is contained in:
5 files changed
+187
No files matched your search
@@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define CENTIMETERS_PER_FOOT 30.48
|
||||
#define CENTIMETERS_PER_INCH 2.54
|
||||
#define INCHES_PER_FOOT 12
|
||||
|
||||
int main(void) {
|
||||
|
||||
float heightCm;
|
||||
int heightFeet;
|
||||
float heightInches;
|
||||
|
||||
do {
|
||||
|
||||
printf("Enter a height in centimeters (<=0 to quit): ");
|
||||
scanf("%f", &heightCm);
|
||||
|
||||
if (heightCm <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
heightFeet = (heightCm / CENTIMETERS_PER_FOOT);
|
||||
heightInches = (heightCm / CENTIMETERS_PER_INCH) -
|
||||
(INCHES_PER_FOOT * heightFeet);
|
||||
|
||||
printf(
|
||||
"%.1f cm = %d feet, %.1f inches\n",
|
||||
heightCm,
|
||||
heightFeet,
|
||||
heightInches
|
||||
);
|
||||
|
||||
} while (heightCm > 0);
|
||||
|
||||
printf("Bye\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user