Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

////////////////////////// defualt Var

// function part2.cpp : This file contains the 'main' function. Program execution
begins and ends there.
//

#include <iostream>
using namespace std;
//////////////////////////////// Defualt var
void print(string name,int discount=0)
{
cout << "Name : " << name << endl;
cout << "Discount : " << discount << endl;
}
int main()
{
//print();
print("Ali");
print("Ali", 20);
}

///////////////////////////////// Overloding fun


// function part2.cpp : This file contains the 'main' function. Program execution
begins and ends there.
//

#include <iostream>
using namespace std;
//////////////////////////////// Overloading function
void print()
{
cout << "Welcome in the print fun\n";
}
void print(string name)
{
cout << "Your Name : " << name << endl;

}
void print(int mark)
{
cout << "Your Mark : " << mark << endl;
}
int main()
{
print();
print("Ali");
print(90);
system("pause");
}

///////////////////////// Var Scop/Recrsion call


// function part2.cpp : This file contains the 'main' function. Program execution
begins and ends there.
//

#include <iostream>
using namespace std;
//////////////////////////////// Overloading function
int i = 1;
void print()
{

cout << "Welcome in the print fun\n";


if (i <= 10) {
i++;
print();
}

}
void fun()
{
cout << "The value of i :" << i << endl;
i += 10;
}
void fun2()
{
cout << "The value of i :" << i << endl;
}
void fun3(int h)
{
cout << "The value of h :" << h << endl;
}

int main()
{
int h = 44;
print();
fun();
fun2();
fun3(h);
system("pause");
}
//////////////////////////////////Pass By Refrences ///////////////////////
// function part2.cpp : This file contains the 'main' function. Program execution
begins and ends there.
//

#include <iostream>
using namespace std;
//////////////////////////////// Overloading function
void Swap(int &a,int &b)
{
int temp;
temp = a;
a = b;
b = temp;

}
int main()
{
int a, b;
cout << "____________ Befor Swap___________\n";
cout << "Num1 : ";cin >> a;
cout << "Num2 : ";cin >> b;
Swap(a,b);
cout << "____________ After Swap___________\n";
cout << "Num1 : " << a << endl;
cout << "Num2 : " << b << endl;
system("pause");
}

You might also like