??what is the syntax for structure??
Answers
Answer:
Syntax is the grammatical structure of sentences. The format in which words and phrases are arranged to create sentences in programming language is called syntax.
Sample notes on structures:
(i) It is a user defined datatype.
(ii) It is a collection of different types of data elements in a single entity.
(iii) When we are working with structures, at the end of the structures semicolon is required.
(iv) Members declared inside structure are called as "Member of structure".
(v) To define a structure, we use Struct keyword.
Syntax:
struct structure-name
{
Datatype1 mem1;
Datatype mem2;
};
Example:
struct Emp
{
int emp_no;
char name[20];
float salary;
};
Explanation:
The name of structure is called as Employee.
Here, struct Emp declares the structure to hold the details of the employee which consists of 3 data fields, namely emp_no, name and salary. These fields are called as Structure members (or) elements.
Hope this information helps!