Wednesday, 31 January 2018


Ques 1) What is Structure ?

Ans-->Structure is a collection of elements of different types referenced under one name, providing a convenient means of storing related information together.

Ques 2) How we can give value to member to structure ?

Ans-->We can give value to member of structure in 2 ways :

i) Using Assignment operator


ii) By taking input from keyboard



  • A structure must be declared as static if it is to be initialized inside function.

i) void main( )
        static struct
             char name[30];
             int age;

ii) void main( )
          struct per
               char name[30];
               int age;
        static struct per pers1={"Piya",14};

  • Structure can be passed as an argument to a function and function can also return a structure.
Ques 3) Can a structure contain a pointer to itself ?

Ans-->Yes, These types of structure are called self referential structure.

Self referential structure are those that refer to themselves with a pointer to structure. We can use these structure in the implementation of linked lists, tree etc.

Ex: struct node
            int data;
            struct node *next;

Notes- SimpleWay2Code

Ques 4) How the structure member are accessible ?

Ans-->i) If the variable is normal variable then structure member need to be linked to structure variable using '.' operator.

ii) If variable is pointer to structure, then structure member need to be linked to structure variable using '-->' operator.

Ques 5) What are the benefit of structure ?

Ans--> Structure is very beneficial in storing inter related information of different datatypes together as a single entity.

Ques 6) What are drawbacks of structure ?

Ans-->i) No access specifier so data members of structure are not protected.

ii) No member function to define the behavior of structure.


No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...