# WAP in C to Create a Structure Distance,read two distances in-feet and inches and print there Additions!

The Program in C to Create a Structure Distance,read two distances in-feet and inches and print there Additions is given below:

``````#include <stdio.h>

struct Distance {
int feet;
int inches;
};

int main() {
struct Distance d1, d2, d3;

printf("Enter first distance (in feet and inches): ");
scanf("%d %d", &d1.feet, &d1.inches);

printf("Enter second distance (in feet and inches): ");
scanf("%d %d", &d2.feet, &d2.inches);

d3.inches = d1.inches + d2.inches;
d3.feet = d1.feet + d2.feet + (d3.inches / 12);
d3.inches = d3.inches % 12;

printf("Addition of two distances: %d feet %d inches", d3.feet, d3.inches);

return 0;
}
``````

## Output:

Enter first distance (in feet and inches): 5
9
Enter second distance (in feet and inches): 7
9
Addition of two distances: 13 feet 6 inches

## Pro-Tips💡

This program uses the `scanf` function to read input from the user and store it in the members of the `Distance` structures.

The addition of the two distances is calculated by adding the feet and inches separately, then adjusting for any inches that exceed 12.

The result is then printed using the `printf` function.

### Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

### Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

### Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

## C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

## C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

## C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

## C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

## C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

## C# Program to Delete Element at Desired position From Array

The Program in C# Program to Delete Element at Desired position From Array is given below: Output: Hello Codeauri Family, enter the number of elements in the array:4Enter…

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X