Define structures with examples

Structure

A structure creates a data type that can be used to group items of possibly different types into a single type.

A structure is a keyword that creates user-defined data types in C and C++.

Example of Structure:

struct {
char name[10];
int age;
float salary;
} Person;

The above example creates a structure and variable name is Person and that has three fields:
name = a name that is a character array
age = an integer value representing the age of the person
salary = a float value representing the salary of the individual

 

Leave a Reply

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