by Dinesh Thakur Category: Array Pointer and Union

We Know that C++ Language Provides us the various types of data types like Int,Float Char etc These are also called the Predefined Data types those are used for Storing the values in the Variables

 The C++ Language also provides us to create a data type which includes all the other data types of int , float and character The Main user defined data type is Structure Which Provides us the facility to make a data types which hold either the int value, float value of character values

 

Structure is the user defined data type that is used for creating a single Variable which makes us possible to declare a value either a int, float or character A user First Make a Structure of different data types with their respective variables A structures is like container which hold all the different variables with their different values and their different length.

 

 Always Remember that the member of the Structure is always Accessed with the help of the. Operator or if we wants to access a variable of the structure then we must use the .(dot) Operator. The Member of the Structure are always Accessed through the Structure variables or For Accessing the Elements of the Structure First you have to create the instance of the Structure then with the help of the Structures you can use the any variable that is defined in the Structure.

 

for declaring the structure we can use this

          struct stu

          {

                   char name[10],lastname[10];

                   int age;

                   float height;

          }

in this structure will consume the 26 bytes of the Memory

10 for name

10 for Lastname

2 for Age

4 For Height

 

 As you can see the Memory size of the Structure is equals to the Number of Bits of particular data types consume And the Total Memory Sized is Judge by the Total Number of Variables with their Respective memory Size Like For

An Integer consume 2 Bytes in the Memory

An Character Consume 1 Byte In Memory

An Float Consume 4bytes in Memory.

 





About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles