# Program to Understand Inch-feet Structure in C

## Inch-feet Structure:

Here , we will write different programs to converts inch to feet by using structure where you will learn about different conversion techniques

## Working of Program :

In the program, we will take the different values and add them after that convert them in to different units.

Run
```#include<stdio.h>
struct Distance
{
int feet;
float inch;
} val1, val2, result;

int main() {
//values for first number
val1.feet = 10;
val1.inch = 20;
// values for second number
val2.feet = 30;
val2.inch = 40;

result.feet = val1.feet + val2.feet;
result.inch = val1.inch + val2.inch;

// convert inches to feet if greater than 12
while (result.inch >= 12.0) {
result.inch = result.inch - 12.0;
++result.feet;
}
printf("\nSum of distances =in feet: %d\', in inches: -%.1f\"", result.feet, result.inch);
return 0;
}
```

### Output :

```Sum of distances =in feet: 45', in inches: -0.0"
```

In the above program,

• We take four values in inches and feet..
• We add them according to theirs units.
• Finally , we convert them in to inches.

## Example :

Lets solve the same problem by same method but this time we use different values for their conversions.

Run
```#include<stdio.h>
struct Distance
{
int feet;
float inch;
} val1, val2, result;

int main() {
//values for first number
val1.feet = 1000;
val1.inch = 2000;
// values for second number
val2.feet = 3000;
val2.inch = 4000;

result.feet = val1.feet + val2.feet;
result.inch = val1.inch + val2.inch;

// convert inches to feet if greater than 12
while (result.inch >= 12.0) {
result.inch = result.inch - 12.0;
++result.feet;
}
printf("\nSum of distances =in feet: %d\', in inches: -%.1f\"", result.feet, result.inch);
return 0;
}
```

### Output :

```Sum of distances =in feet: 4500', in inches: -0.0"
```

### Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

## Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others