Explain structure with syntax and example.
Structure: The Structure is a user defined data supported by object oriented programming. It has almost similar properties that any other user defined data type possess except all members are public by default.
One can create a structure using following syntax:
struct structure_name
{
data_member1;
data_member2 ;
.
.
data_memberN;
};
Example:
#include<iostream.h>
#include<conio.h>
struct demo
{
int a;
};
void main()
{
demo d;
clrscr();
cout<<"\nEnter a value for demo's a";
cin>>d.a;
cout<<"\nThe Value is "<<d.a;
getch();
}