You are on page 1of 16

# DEPARTMENT OF TECHNICAL EDUCATION

Name :M.Subramanyam
Designation :Senior Lecturer
Branch :Computer Engg.
Year/Semester :III Semester
Subject :UNIX & C
Subject Code :CM-304
Topic :Structures
Duration :50 Min
Sub Topic :Functions and structures
Teaching Aids :PPTs,Animation
CM304.79 1
Recap

##  How to find the size of the structure?

 What is nested structure?
 How to access members using pointer to
structure?

CM304.79 2
Objectives

## On completion of this period, you would be able to know …

 Passing members of structure variables separately to a
function.
 Passing an entire structure to a function.
 Passing pointer to structure as a argument to a function.
 Return structure from a function.

CM304.79 3
Structures and Functions

##  Passing address of the structure to a function.

CM304.79 4
Passing Structure Elements to Function

##  Any ordinary variables can be passed to a

function.
 Members of a structure variable can also be
passed to a function.

CM304.79 5
Example

CM304.79 6
Passing an Entire Structure to a Function

##  We can pass int, float, char etc., variables to a

function as its arguments.
 A structure variable can also be passed to a
function as its argument.

CM304.79 7
Example

CM304.79 8
Passing Pointer to Structure

a function.

##  Structure can be manipulated using pointer.

CM304.79 9
Example

CM304.79 10
Returning structure from a function

CM304.79 11
Ex:

Return
type

CM304.79 12
Summary

## In this class, you have learnt about…

 Passing structure members as function
arguments.
 Passing structures as function arguments.
 Passing address of the structure as function
argument.
 Function returns structure.

CM304.79 13
Quiz

##  Structures are passed to functions only by

pass by reference method.
true/ fals
e

CM304.79 14
Quiz

##  Structures are passed to functions only by

pass by reference method.
true/ fals
e

CM304.79 15

## 1. Explain the method of passing structures as

arguments to function.

## 3. Write a program to define structure with

tagname state with fields statename, no.of
districts and total population. Read and display
the data by passing the address of the
structure to user defined function.

CM304.79 16