VC++ tutorial

Visual C++ Examples

How To Add Menu In VC++

Structure In VC++
Previous Home Next

A structure is a collection of variable types grouped together. you can refer to structure as a single variable, and to its parts as a single variable, and to its parts as members of that variable by using the dot(.) operator. The structure name becomes a user-defined data type and may be used the same way as other built in data types such as int, double, char and string.

A structure is data type it contain other data types which are grouped together into a single user-defined type. It is often desirable to group data of different types and work with that grouped data as one entity. We now have the power to accomplish this grouping with a new data type called a structure.

#include <iostream>
using namespace std;
struct Employes {
char Name[20];
int Age;
float Salary;
int main() 
Employes E1;
cout << "Enter Full Name: ";
cin >>(E1.Name, 50);
cout << "Enter Age: ";
cin >> E1.Age;
cout << "Enter Salary: ";
cin >> E1.Salary;
cout << "\nDisplaying Information."<< endl;
cout << "Name: " << E1.Name << endl;
cout <<"Age: " << E1.Age << endl;
cout << "Salary: " << E1.Salary << endl;
return 0;

Declaring a structure:

structure is declared by using the keyword struct followed by structure name, then structure members (variables) are defined with their type and variables names inside the open and close braces {and}. end off the close braces ends with a semicolon(;).

Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Comment / Feedback: