You are on page 1of 7

CS-212

OBJECT ORIENTED
PROGRAMMING
MEHREEN TAHIR
Functions
• Perform specific task
• Reusability
Functions
• Prototype
• Definition
• Call
Functions
• Local and global variables
• Built in functions
• User defined functions
Functions
• Passing arrays to functions
• Function overloading
• Function signature
– A function's signature includes the function's name and
the number, order and type of its formal parameters.
– Two overloaded functions must not have the same
signature.
– The return value is not part of a function's signature.
Functions
• int Divide (int n, int m)
• double Divide (int n, int m)
• float Divide (int x, int y)

• Make overloaded functions of sum


Functions
int sum(int x[],int y){ //how about int sum(int x[5])
std::cout<<"size of x= "<<sizeof(x);
for (int i=0;i<y;i++){ // for (int i=0;i<5;i++){
std::cout<<"array="<<x[i];}
return 0;}
void main(){
int a[5]={31,32,33,34,35};
std::cout<<"size of a= "<<sizeof(a)/sizeof(a[0]);
sum(a,5); }

You might also like