Structures in C

Download as
 PPT
Presentation Description 

No description available

By:
 (2 month(s) ago)  
hi, i want this ppt......... how to download it................plz help me out......

By:
 (3 month(s) ago)  
hi, i want this ppt......... how to download it................plz help me out......

Views: 557
Like it  ( Likes) Dislike it  ( Dislikes)
Added: December 24, 2008 This Presentation is Public 
Presentation Category : Education All Rights Reserved
Tags Add Tags
Presentation Statistics
Views on authorSTREAM: 539 | Views from Embeds: 18
Others - 18 views
Presentation Transcript

Slide 1:Structure Structure: The array can be used to represent a group of related data item that belong to the same datatype if we want to represent a collection of data item of different datatypes. Using a single name, C supports a constructed datatype known as structure.


Slide 2:Structure definition: struct book-bank { char title[20]; char author[5]; int pages; float price; } The keyword struct declares the structure that holes the details of four fields namely title, author, pages, price. These fields are called structure element or members. Each member may belong to different datatype. Bookbank is the name of structure and is called structure tag.


Slide 3:struct book-bank { char title[20]; char author[5]; int pages; float price; } book1,book2,book3; Members of the structure are themselves not a variable. They do not occupy any memory and till associate with structure variable such as book1


Slide 4:Comparison of structure variables: Two variables of the same structure tube can be compare the same way as ordinary variables. If s1 and s2 belong to some structure then the following operation are valued. Operation Meaning s1 = s2 Assign s1 to s2 s1 = s2 Compares all the members of s1 & s2 and written 1 if they are equal or 0 otherwise. s1 ! = s2 Written 1 if all the members are not equal, 0 otherwise.


Slide 5:Arrays of Structure: Struct class student [100]; Define C Array called student that consist of 100 elements. Each elements is define to be of the struct.class. struct marks { int sub 1; int sub 2; int sub 3; }; main() { Static struct mark student [s] = {{80,85,90}, {92,97,98}, {96,95,94}} }


Slide 6:This declares a student as a array of three elements Student [0]. Sub1=80; Student [0]. Sub2 =85; …………………….. …………………….. Student [2] . sub3=92;


Slide 7:Program # include # include struct personal { char name [20]; int day; char month [10]; int year; float salary; } main() { struct personal person; printf (“input values”); scanf (“%s%d%s%d%f” person.name & person.day, person.year, person.salary); } Output Input Value Divya 10 may 2008 5000.00


Slide 8:Union Union: Union is similar as structure. The major distinction between them in terms of storage. In structure each member has its own storage location whereas all the members of union uses the same location. The union may contain many members of different data type it can handle only one member at a time union can be declared using the keyword union.


Slide 9:Union item { int m; float x; char c; } code; This declare a variable code of type union item.