Program to to calculate distance b/w two heights passing structure as pointers to the function

#include<stdio.h>
struct height1
{
    int a,b
} h1;
//int func(struct height1 *h1);
main()
{
    int diff;
    printf("Enter the two heights to get the difference b/w them.\n");
    scanf("%d",&h1.a);
    scanf("%d",&h1.b);

    diff = height(&h1);

}
int height(struct height1 *h1)
{
    if((*h1).a > (*h1).b)
    {

    printf("Difference of heights is %d",(*h1).a-(*h1).b);
    }
    else if((*h1).b > (*h1).a)
    {
         printf("Difference of heights is %d",(*h1).b-(*h1).a);
    }
    else if((*h1).a==(*h1).b)
    {
        printf("Difference of heights is 0");
    }

}

21_2

Program to add and subtract two complex numbers using structures.

#include<stdio.h>
#include<conio.h>
struct hi
{
    int real1,real2;
    int comp1,comp2;
} arith;
main()
{
    int a;
    printf("Enter the real and imaginary part of first number respectively\n");
    scanf("%d",&arith.real1);
    scanf("%d",&arith.comp1);
    printf("Enter the real and imaginary part of second number respectively\n");
    scanf("%d",&arith.real2);
    scanf("%d",&arith.comp2);
    printf("Select the operation\n1. Addition\n2. Subtraction\n");
    scanf("%d",&a);
    if(a==1)
    {
        printf("Addition - %d + %di",arith.real1+arith.real2,arith.comp1+arith.comp2);
    }
    else if(a==2)
    {
        printf("Subtraction - %d + (%di)",arith.real1-arith.real2,arith.comp1-arith.comp2);
    }
    else
        {
            printf("Not a valid operation.");

        }

}

 

Output:

21_1