C Program to add two numbers using 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

Run it Now
#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("\nThe sum is : %d", t.z);

    return 0;
}

Output:

Enter two numbers : 10 20
The sum is : 30