pgrm_010.cpp
Problem Statement
pgrm_010.cpp
Default argument
Source Code
cpp
#include<iostream>
using namespace std;
class Interest {
public:
float simpleInterest(float p, float t = 5.0, float r = 1.0) {
return (p * t * r) / 100;
}
};
int main() {
Interest obj;
cout << "Principle only = " << obj.simpleInterest(10000) << endl;
cout << "Principle and Time = " << obj.simpleInterest(10000, 8.0f) << endl;
cout << "Principle, Time and Rate of Interest = " << obj.simpleInterest(10000, 8.0f, 5.0f) << endl;
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
● Author - Amit Dutta · Updated - 10 Jul 2026