C++ Program using structure


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


struct struct_name { };


Example: How to implement structure in C++

Run it Now
#include<iostream>
using namespace std;

struct Test {
    int x, y;
};

int main() {

    struct Test t;

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

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

    return 0;
}

Output:

The x value is :10
The y value is :20