It is a data type. We can give different types of data types inside the structure data type. So it is called Heterogeneous data type.
EX:
Let's take the student's information. We need to buy the student's name, age, and weight.
Here name is string data type.age is integer data type.
weight is float data type.These three are different data type.We cannot add it to array.
The structure data type was introduced to solve this problem.
Name, age, weight can be stored inside the structure data type.
syntax:
struct name
{
//structure members
};
struct->this is keyword.
name-> is the name that can be given to this structure data type.
structure members->It can be any data type like integer,char,float,...etc.
EX:
struct student
{
char name [30];
int age ;
float weight;
};
Explain:
struct is the keyword.student is the name of the structure.
name,age,weight are all structure members.