Sunteți pe pagina 1din 13

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name : Murali Krishna Chintala
Designation : Lecturer in CME
Branch : Computer Engineering
Institute : SUVR & SR GPW, Ethamukkala
Year/Semester : III Semester
Subject Name : UNIX & C
Subject Code : CM – 304
Major Topic : Understand Modular Programming
Duration : 50 Min
Sub Topic : Function prototype
Teaching Aids : PPT, Animations

CM304.64 1
Objective

On completion of this period, you would be able


to
• Understand the purpose of function prototypes.

CM304.64 2
Recap

In the previous class, you have learnt

• Understand different functions.

• Function calling types.

CM304.64 3
Function prototype

• Tells the compiler the type of data returned by the


function.

• The number of arguments the function receives.

• Types of arguments.

• Order of the arguments.

CM304.64 4
Function prototype

Syntax
• Return_ type function_name(dt1,dt2..dtn);

• Return_ type is the type of data returned by the


function.

• dt1,dt2..dtn are the types of data fed as arguments.

CM304.64 5
Function prototype
Example:1

#include<stdio.h>
int big(int,int,int);/*function proto type*/
main()
{
int a,b,c;
scanf(“%d%d%d”,&a,&b,&c);
printf(“biggest is:%d”,big(a,b,c));
}

CM304.64 6
Function prototype
Contd..

int big(int x,int y,int z)


{
int max=x;
if(y>max)
max=y;
if(z>max)
max=z;
return(max);
}
CM304.64 7
Summary
At the end of the class, you have learnt about..

1.The types of data returned by the function.

2. The number of arguments the function expects to


receive.

3.The types of arguments.

4. The order in which these arguments are expected

CM304.64 8
QUIZ
1. Function proto type tells the compiler..

a) Type of data returned by the function

c) Number of arguments the function receives

e) Types of arguments

g) All the above

CM304.64 9
QUIZ

1. Function proto type tells the compiler..


 Type of data returned by the function

 Number of arguments the function


receives

 Types of arguments

 All the above


CM304.64 10
QUIZ

2. Compiler uses function proto types to validate.


a) System calls

c) Function calls

e) Recursive calls

g) None

CM304.64 11
QUIZ
2. Compiler uses function proto types to validate.
 System calls

 Function calls

 Recursive calls

 None

CM304.64 12
Frequently Asked Questions

1.Explain about function prototypes?


(March/Apr 2007)

2.What is the necessity of function prototype in


programs? (October 2004)

CM304.64 13

S-ar putea să vă placă și