What is the useful effect of using struct? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the useful effect of using struct?

20th Jan 2019, 2:46 PM
Mohammad Saidul Arefin Taibin
Mohammad Saidul Arefin Taibin - avatar
3 Answers
+ 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).
20th Jan 2019, 4:39 PM
Infinity
Infinity - avatar
+ 2
It is used to store data of different data types. Example: int,string,boolean,long etc inside one struct.
20th Jan 2019, 6:53 PM
Akshay Madrikar
Akshay Madrikar - avatar
+ 1
Yes. I got the answer. Thank you all for making me understand.
21st Jan 2019, 6:54 PM
Mohammad Saidul Arefin Taibin
Mohammad Saidul Arefin Taibin - avatar