Right Money Management App For Your Financial Goals
ย
Functions in c++,
1. ๏ By:
๏ P.Divya,181602
๏ S.sandhiya,181611
๏ II B.SC maths [ca]
๏ S.B.K.college
๏ Aruppukottai
๏ TO:
๏ K.PADMA PRIYA M.Sc,M.Phil
๏ Asst proffesor
๏ Dept of maths ca
๏ S.B.K.college
๏ Arruppukottai
๏
2. a function is a group of statements that
together perrform a task, function declaration
tells the complier about a functtionโs name ,
return type and parameters.A function
definition provides the actual body of the
function .The c++ standard library provides
numerous built in functions that our program
can call.
3. ๏ Main()function is the entry point of any c++ program.When a c++
program is executed,the execution control goes directly to the main
()function .Every c++ program have a main()function.
๏ main()
๏ {
statements
}
If the main funtion has a return type. The syntax is
int main()
{
โฆโฆโฆ.
โฆโฆโฆ.
return 0;
}
4. Function prototyping is one very useful feature of
c++ function.Function prototype declaration
statement in the calling program
type function-name(argument-list);
Eg:
float volume (int a,int b,int c)
{
float v=a*b*c;
โฆโฆ.
โฆโฆ.
}
5. ๏ The call by reference method of passing arguments to a function
copies the reference of an argument into the formal prameter.
๏ void swap(int a,int b)
๏ {
๏ int t= a;
๏ a=b;
๏ b=t;
๏ }
๏ Using pointers as follows
๏ void swap(int *a,int*b)
๏ {
๏ t=*a;
๏ *a=*b;
๏ *b=t;
๏ }
6. A c++ function can return a reference in a similar
way as it returns a pointer .
int & max(int&x,int&y)
{
if(x>y)
return x;
else
return y;
}
7. ๏ Inline fun is a fun which when invoked requests the
compiler to replace the calling statement with its
body.A keyword inline is added before the fun name to
make it inline.
๏ inline function-header
๏ {
๏ function body
๏ }
๏ Eg;
๏ inline double cube(double a)
๏ {
๏ return (a*a*a);
๏ }
8. ๏A default argument is a value provided in a
function declaration that is automatically
assigned by the compiler if the caller of the
function doesnโt provide a value for the
argument with a default value.
9. ๏Function overloading (also method
overloading )is a programming concept that
allows programmers to define two or more
functions with the same name and in the same
scope .