Monday, July 4, 2022

CALL BY VALUE FUNCATION #THEHACKERS@

 #include<iostream>

using namespace std;


void swap(int a, int b)

{

    int temp;

    temp=a;

    a=b;

    b=temp;

    cout<<a<<" "<<b<<endl;

}

int main()

{

    int x=10,y=20;

    swap(x,y);

    cout<<x<<" "<<y<<endl;

}

DEFAULT ARGUMENTS USING FUNCATION OVERLOADING #THEHACKERS@

 #include<iostream>

using namespace std;


int max(int a=0, int b=0, int c=0)

{

    return a>b &&a>c ? a:(b>c?b:c);

}

int main()

{

    cout<<max()<<endl;

    cout<<max(10)<<endl;

    cout<<max(10,20)<<endl;

    cout<<max(10,20,30)<<endl;

}

DEFAULT ARGUMENTS #THEHACKERS@

 #include <iostream>

using namespace std;

 


int sum(int x, int y, int z = 0, int w = 0) 

{

    return (x + y + z + w);

}

 


int main()

{

    cout << sum(10, 15) << endl;

 

    cout << sum(10, 15, 25) << endl;


    cout << sum(10, 15, 25, 30) << endl;

    return 0;

}

Sunday, July 3, 2022

FUNCATION #THEHACKERS@

 #include<iostream>

using namespace std;


int add( int x, int y)

{

    int z;

    z=x+y;

    return z;

}

int main()

{

    int b,  c;

    int a=10;b=20,c;

    c=add(a,b);

    cout<<" the sum is "<<c;

}

CONSTRUCTURE IN PARENT CLASS

class Parent {     public Parent()     {         System.out.println("Parent Constrcutor");     }              } class Child extend...