unit4 - C Data Types: Primary data types Derived data types...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
C Data Types: Primary data types Derived data types User-defined data types Derived Types Function Type Structure Type Array Type Pointer Type Union Type Array Collection of one or more related variables of similar data type grouped under a single name Structure – Collection of one or more related variables of different data types, grouped under a single name In a Library, each book is an object , and its characteristics like title, author, no of pages, price are grouped and represented by one record . The characteristics are different types and grouped under a aggregate variable of different types. A record is group of fields and each field represents one characteristic. In C, a record is implemented with a derived data type called structure . The characteristics of record are called the members of the structure.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
book bookid title author pages price STRUCTURE- BOOK struct book { int book_id ; char title[50] ; char author[40] ; int pages ; float price ; }; Book-1 BookID: 1211 Title : C Primer Plus Author : Stephen Prata Pages : 984 Price : Rs. 585.00 Book-2 BookID: 1212 Title : The ANSI C Programming Author : Dennis Ritchie Pages : 214 Price : Rs. 125.00 Book-3 BookID: 1213 Title : C By Example Author : Greg Perry Pages : 498 Price : Rs. 305.00 Structure tag integer book_id Array of 50 characters title Array of 40 characters author integer pages float price 2 bytes 50 bytes 40 bytes 2 bytes 4 bytes struct < structure_tag_name > { data type < member 1 > data type < member 2 > …. …. …. …. data type < member N > } ; Memory occupied by a Structure variable
Background image of page 2
Initialization of structure Initialization of structure variable while declaration : struct student s2 = { 1001, “ K.Avinash ”,
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

unit4 - C Data Types: Primary data types Derived data types...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online