Question2
Assignment C++
Q.2: Explain Structures? How they can be utilized to define user defined data types?
Answer:
We can use structures by defining structure variables, as in above example when the structure
is declared now it will behave as the new data type i.e. the structure name as home
data type and the variable attached to it will have the data type of type home(having 1 integer and 2 float) to define the structure variable we declare the variables following structure name and you can define as many structure variables you can.
will be the
09CE37
6
Question2
Syntax:
Assignment C++
home citizen, defence, qasimabad, latifabad;
int plot;
As we see above the syntax is same as both are now data type.But home is also a data type but with multiple data types.
int is integer data type but
The definition of the structure variable set aside the memory for the variable. The amount of memory depends up on the number and type of the members of the structure. In above structure variables citizen, defence, qasimabad, latifabad will occupy 18 bytes of memory ( 4 bytes of int , 10 bytes of char, 4 bytes of int). In this way we can make our own data type with Structures.
09CE37
7
Lebih dari sekadar dokumen.
Temukan segala yang ditawarkan Scribd, termasuk buku dan buku audio dari penerbit-penerbit terkemuka.
Batalkan kapan saja.