DO NOT MISS

Ads

Thursday, 15 December 2016

Structures in C-Language


Structure are used to store different data types values into a single variable. Know a days every it project executes through the structure concept.
(or)

It is an user defined data type which is used to store different (or) similar data types values.



Definition:-

Collection of values with similar (or) different data types is known as a structure.


Syntax:-
struct tagname
       {
           member 1;
           member 2;
                 :
                 :
           member n;
       };

In the above syntax , struct is a key word which defines the structure. tagname is   an identifiar. Data members are nothing but variables.

Ex:-
struct student
{
int no;
char name[20];
};


In the above example stud is a user defined structure (or) data type. This user defined data type contains two members.

1. No.of int type
2. No.of char type

It means the user defined data type stud stores are defines two types of values

Structure variable :-
The name given to the memory for storing the members of the structure is known as structure variable.

Syntax:-
[struct] structurename structurevariablename;
(or)
[struct] structurename structure variable1, structure variable2,............structure variable n;

Ex :-
Student s;
Student s1,s2;


Accessing data members of the structure:-
We can access the data members of the structure by using period operator ( . ).

Ex:-
s.no=25;
s.name="prasad";
s.no=s1.no+s2.no.





  

---------------------------------------------------------------------------------------------------------------
>> Back to Notes of C-Language (Topic Wise)
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------


Greataims

 
Copyright © 2016 Computersadda. Designed by @ Computersadda Team - Published By Greataims