C++ Program to add two numbers using a structure
In this program, You will learn how to add two numbers using structure in C++.
20 = 10 + 10
30 = 10 + 20
Example: How to add two numbers using structure in C++.
#include<iostream>
using namespace std;
struct Test {
int x, y, z;
};
int main() {
struct Test t;
cout << "Enter two numbers:";
cin >> t.x >> t.y;
t.z = t.x + t.y;
cout << "Sum is :" << t.z;
return 0;
}
Output:
Enter two numbers:10 20
Sum is :30