+ 1
What is the useful effect of using struct?
3 Antworten
+ 3
It allows you to create your own data type.
A simple example:
int a[5] will store 5 elements of integer data type only
On the other hand, if we define
struct array {
string name;
int age;
};
// A new data type
Now, struct array a[5] can store elements in each cell of the array which are both string as well as integer, unlike the previous case. In other words, each cell is further partitioned into two new cells(in this case).
+ 2
It is used to store data of different data types. Example: int,string,boolean,long etc inside one struct.
+ 1
Yes. I got the answer. Thank you all for making me understand.