C Program to add two numbers using a structure


In this program, You will learn how to add two numbers using structure in c.


struct Test { 
   int x, y, z; 
};

Example: How to add two numbers using structure in c.

#include<stdio.h>

struct Test {
    int x, y, z;
};

int main() {

    struct Test t;

    printf("Enter two numbers : ");
    scanf("%d%d", &t.x,&t.y);

    t.z = t.x + t.y;

    printf("The sum is : %d", t.z);

    return 0;
}

Output:

Enter two numbers : 20 30
The sum is : 50