-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut17.cpp
49 lines (40 loc) · 1.65 KB
/
tut17.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Inline Functions , Default Arguments & Constant Arguments in C++
#include<iostream>
using namespace std;
// inline int product (int a,int b){
// return a*b;
// }
int product(int a, int b){
// Not recommended to use below lines with inline functions.
static int c=0; // This executes only once
c = c+1; // Next time this function is run , the value of c will be retained.
return a*b+c;
}
float moneyReceived(int currentMoney, float factor=1.04){
return currentMoney*factor;
}
// use of constant arguments.
// int strlen(const char *p){
// }
int main(){
// int a,b;
// cout<<"Enter the value of a and b "<<endl;
// cin>>a>>b;
// cout<<"The product of a and b is "<<product(a,b)<<endl;
// cout<<"The product of a and b is "<<product(a,b)<<endl;
// cout<<"The product of a and b is "<<product(a,b)<<endl;
// cout<<"The product of a and b is "<<product(a,b)<<endl;
// cout<<"The product of a and b is "<<product(a,b)<<endl;
// cout<<"The product of a and b is "<<product(a,b)<<endl;
// cout<<"The product of a and b is "<<product(a,b)<<endl;
// cout<<"The product of a and b is "<<product(a,b)<<endl;
// cout<<"The product of a and b is "<<product(a,b)<<endl;
// cout<<"The product of a and b is "<<product(a,b)<<endl;
int money = 100000;
// Use of default argument , it already use the factor.
cout<<"If you have "<<money<<" Rs in your bank account , you will receive "<<moneyReceived
(money)<<"Rs after 1 year . "<<endl;
cout<<"For VIP : If you have "<<money<<" Rs in your bank account , you will receive "<<moneyReceived
(money,1.1)<<"Rs after 1 year . ";
return 0;
}