C++ Program using a structure


In this program, You will learn how to implement structure in C++.


struct struct_name { 
      //variable declaration
};

Example: How to implement structure in C++.

#include<iostream>
using namespace std;

struct Test {
    int x, y;
};

int main() {

    struct Test t;

    t.x = 10;
    t.y = 20;

    cout << "x value is:" << t.x;
    cout << "\ny value is:" << t.y;

    return 0;
}

Output:

x value is:10
y value is:20