Professional Documents
Culture Documents
15 Ways to Define Functionspdf Lyst8300 (1)
15 Ways to Define Functionspdf Lyst8300 (1)
15 Ways to Define Functionspdf Lyst8300 (1)
Function
① Ways to
define a function
② Header files and Library files
to
Waysdefine a function
1 . Takes
Nothing
,
Returns
Nothing
.
2 Take something ,
Returns
Nothing
.
3 Takes Nothing , Something
Return
Return something
4 . Take Something ,
a D
DA F2()
f(()
E
S int a
,
b;
printf ("d", a) ;
f2C)
Y 3
TNRN
#include Stdio h> function
I
- -
.
- value)
returned
return o ;
E call
void add (C function
& TN
I
int
Printf
a b ,C;
,
("Enter two numbers") ; function
scanf ("d % d , a &b) ; , definition
c= a +bi
(sum is % d" ) ;
printf ,
RN
No return Keyword >
-
3
#include < Stdio h > TSRN
.
int c ;
c = a+ b ;
% d" C) ;
Printf /"sum is ,
3
#include Stdio n) .
INRS return
int add() ; ① value return
-
int main() a 2d /
E ② control return
int S ;
LAT
s= add) ;
yod" , s) ; You can return
printf ("sum is
only one value
return O
3
int add (
E +
in a b , 2;
,
two numbers") ;
Printf(Enter a , b) ;
scanf (" . d % d" ,
c = a +b ;
return C ;
3
#include Stdio SRS. h>
%.d" , s) ;
printf ("Sum is
return O ;
3
int add (inta ,
in+ b)
E
int ;
c = a + bi
return c;
3
predefined function
Definition of
>
- Library files
predefined function
Declaration of
Header files
>
-
auself
Ask
1 .
Function call vs Function Definition vs Function Declaration
.
2 Function saves memory
3 .
maine is a userdefined function
.
8 .
call by value
.
9 Function Prototype = function declaration
10 .
Can We Call maine function (l ? yes
topmate io/mysing
.
first
-
C
second .
9
Finderested
&
add ;
in
Printf ("y d" add (3
.
,
, 4));