make structure table ad its all struture,examples
Answers
Answered by
0
C Structure is a collection of different data types which are grouped together and each element in a C structure is called member.
If you want to access structure members in C, structure variable should be declared.
Many structure variables can be declared for same structure and memory will be allocated for each separately.
It is a best practice to initialize a structure to null while declaring, if we don’t assign any values to structure members.
DIFFERENCE BETWEEN C VARIABLE, C ARRAY AND C STRUCTURE:
A normal C variable can hold only one data of one data type at a time.
An array can hold group of data of same data type.
A structure can hold group of data of different data types and Data types can be int, char, float, double and long double etc.
If you want to access structure members in C, structure variable should be declared.
Many structure variables can be declared for same structure and memory will be allocated for each separately.
It is a best practice to initialize a structure to null while declaring, if we don’t assign any values to structure members.
DIFFERENCE BETWEEN C VARIABLE, C ARRAY AND C STRUCTURE:
A normal C variable can hold only one data of one data type at a time.
An array can hold group of data of same data type.
A structure can hold group of data of different data types and Data types can be int, char, float, double and long double etc.
Answered by
0
Structure is a collection of variables of different data types under a single name. It is similar to a class in that, both holds a collecion of data of different data types.
For example: You want to store some information about a person: his/her name, citizenship number and salary. You can easily create different variables name, citNo, salary to store these information separately.
However, in the future, you would want to store information about multiple persons. Now, you'd need to create different variables for each information per person: name1, citNo1, salary1, name2, citNo2, salary2
You can easily visualize how big and messy the code would look. Also, since no relation between the variables (information) would exist, it's going to be a daunting task.
A better approach will be to have a collection of all related information under a single name Person, and use it for every person. Now, the code looks much cleaner, readable and efficient as well.
hope it helps.....
**IF IT HELPS THEN PLEASE MARK IT AS A BRAINLIEST ANSWER. . .
For example: You want to store some information about a person: his/her name, citizenship number and salary. You can easily create different variables name, citNo, salary to store these information separately.
However, in the future, you would want to store information about multiple persons. Now, you'd need to create different variables for each information per person: name1, citNo1, salary1, name2, citNo2, salary2
You can easily visualize how big and messy the code would look. Also, since no relation between the variables (information) would exist, it's going to be a daunting task.
A better approach will be to have a collection of all related information under a single name Person, and use it for every person. Now, the code looks much cleaner, readable and efficient as well.
hope it helps.....
**IF IT HELPS THEN PLEASE MARK IT AS A BRAINLIEST ANSWER. . .
Similar questions