IMTS PGDCA (Computer fundamental & c programming)

Page 242

COMPUTER FUNDAMENTAL & C PROGRAMMING

237

UNIT – VII 7

Introduction Structure and union, which is method for placing data of different types. A structure is

convenient tool for handling a group of logically related data items. But arrays can be used to represent a group of data items that belong to the same type. In this unit we shall introduce three different derived data types such as structure & union, arrays and functions. We discuss how structure & union, arrays and functions can be defined and used in C.

8

Objectives After studying this unit, you should be able to 

Create a structure & union and reference each of its members.

Create and manipulate various types of array.

Create and manipulate function in C.

Understand the term scope, local and global and how each will affects

variables

within functions. 9

Structure And Unions 9.2

I ntroduction C provides a constructed data type known as structure, which is a method for packing

data of different types. A structure contains one or more data items of different data type in which the individual elements can differ in type. The individual element in structure is called members. Example: You might want to process information on students, in the category of names and marks. Here we can declare the structure ‘student’ with the fields, names and marks and we can assign their appropriate data types. These fields are called members of the structure. 9.3

S tructure Definition or Template Declaration The structure creates a format that may be used to declare structure variables. The

general form for defining the structure as struct structure_name { type structure_element 1; type structure_element 2; -----------type structure_element n; };

FOR MORE DETAILS VISIT US ON WWW.IMTSINSTITUTE.COM OR CALL ON +91-9999554621


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.