-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d732d96
commit c9afffa
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <stdio.h> | ||
|
||
struct metric | ||
{ | ||
float meters; | ||
float centimeters; | ||
}; | ||
|
||
struct British | ||
{ | ||
float feet; | ||
float inches; | ||
}; | ||
|
||
int main() | ||
{ | ||
struct metric m; | ||
struct British b; | ||
|
||
printf("Enter the metric distance (meter): "); | ||
scanf("%f", &m.meters); | ||
printf("Enter the metric distance (centimeter): "); | ||
scanf("%f", &m.centimeters); | ||
|
||
b.feet = 3.28084 * m.meters; | ||
b.inches = 0.3937008 * m.centimeters; | ||
|
||
printf("How do you wish to display the result?\n"); | ||
printf("1. Feet and inches\n"); | ||
printf("2. Meters and centimeters\n"); | ||
|
||
int choice; | ||
scanf("%d", &choice); | ||
switch (choice) | ||
{ | ||
case 1: | ||
printf("Result: %f feet %f inches\n", b.feet, b.inches); | ||
break; | ||
case 2: | ||
printf("Result: %f meters %f centimeters\n", m.meters, m.centimeters); | ||
break; | ||
default: | ||
printf("Invalid choice\n"); | ||
} | ||
return 0; | ||
} |