C++ Introduction of Structure

      No Comments on C++ Introduction of Structure

A structure is a collection of simple variables.The variable in a structure can be of different types.
The data items in structure are call as ‘members’ of structure. An understanding of a structure is very essential since it forms the building block for understanding ‘classes and objects’.

Example:-

#include<iostream.h>
#include<conio.h>
struct scan
{
int age;
double salary;
};

void main()
{
clrscr();
scan s1;
s1.age=26;
s1.salary=35000;
cout<<"Age= "<<s1.age<<endl;
cout<<"Salary= "<<s1.salary<<endl;
getch();
}

OUTPUT:-

Leave a Reply

Your email address will not be published. Required fields are marked *