Skip to content

Commit

Permalink
11 | 11 | sharafat
Browse files Browse the repository at this point in the history
  • Loading branch information
SharafatKarim committed Aug 12, 2023
1 parent d732d96 commit c9afffa
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions solutions/sharafat/11/11.c
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;
}

0 comments on commit c9afffa

Please sign in to comment.