Академический Документы
Профессиональный Документы
Культура Документы
ANDHRA PRADESH
Name : Murali Krishna Chintala
Designation : Lecturer in CME
Branch : Computer Engineering
Institute : SUVR & SR GPW, Ethamukkala
Year/ Semester : III Semester
Subject : UNIX & C
Subject Code : CM – 304
Topic : Understand Modular Programming
Duration : 50 Min
Sub Topic : Function call techniques.
Teaching Aids : PPT, Animations
CM304.63 1
Objective
CM304.63 2
Parameters can be passed to a function in two
ways
• Call by value
• Call by reference
CM304.63 3
Call by value
CM304.63 4
Call by reference
CM304.63 5
Call by reference
Contd..
CM304.63 6
Types of user defined functions
CM304.63 7
Functions with no arguments and
no return values
Syntax:
main()
{
----
fun()
---
}
fun()
{
---
}
CM304.63 8
Functions with no arguments and
no return values
Contd..
CM304.63 9
Functions with no arguments and
no return values
Contd..
Example:
#include <stdio.h>
void fun();/* function proto type*/
main()
{
fun();
}
CM304.63 10
Functions with no arguments and
no return values
Contd..
Example:
void fun()
{
int n;
scanf( “%d”, &n);
printf( “%d”, n);
}
CM304.63 11
Functions with arguments and
no return values
CM304.63 12
Functions with arguments and
no return values Contd..
Example:
#include <stdio.h>
int sum(int,int); /*function prototype*/
main()
{
scanf(“%d%d”,&x,&y);
printf(“%d”,sum);
}
CM304.63 13
Functions with arguments and
no return values Contd..
Example:
CM304.63 14
Functions with arguments and
return values
CM304.63 15
Contd..
Example:
#include<stdio.h>
int sum(int,int);
main()
{
int x,y,z;
scanf(“%d%d”,&x,&y);
z=sum(x,y);
printf(“%d”,z);
}
CM304.63 16
Contd..
Example:
CM304.63 17
Summary
At the end of this class, you have learnt about..
CM304.63 18
QUIZ
CM304.63 19
QUIZ
One value
Two values
Many values
CM304.63 20
QUIZ
CM304.63 21
QUIZ
CM304.63 22
Frequently Asked Questions
CM304.63 23