Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
When using a predefined function, need to include the library it is found in:
#include <cmath>
Any value that a function call supplies to the function is known as an argument of
the function call.
Any results calculated by and returned by the function call are known as the return
value.
Lesson 3
For example:
sqrt (x)
sqrt(b * b - 4 * a * c)
Each function takes input of a particular type. For example: sqrt expects a number.
Example:
a = 75;
cout << "Square root of 100 is" << sqrt(100)
<< endl;
cout << "Another root:" <<sqrt(2 * a + 100)
<< endl;
Lesson 3
Slide 6:
6 Functio
oning of Predefine
P
ed Functiions
When we
w use sqrt((x) inside main():
m
int ma
ain()
{
......
0);
x = sqrt(100
......
rn 0;
retur
}
7 Functio
oning of Predefine
P
ed Functiions (con
nt'd)
Slide 7:
When we
w use sqrt((x) inside main:
m
1) Inputt value or parameter
p
value
v
x is pa
assed to sq
qrt function..
ution of ma
ain() functio
on is tempo
orarily suspeended.
2) Execu
f
beccomes activ
ve and com
mputes the o
output or re
return valuee using som
me
3) sqrt function
method unknown to
t us.
r
value
e is transferrred back to
o main() fu
unction, which resumes the
4) The return
computa
ation using the return value.
Lesson 3
abs(int)
labs(long)
double
fabs(double)
double
double
fmod(double,double)
Lesson 3
Return Type
double
Function Call
sqrt(double)
double
pow(double,double)
double
exp(double)
double
ceil(double)
double
floor(double)