A worker takes a job for 5 days. His pay for the day 1 is Rs. X, for day 2 is Rs. 2X and so on. Develop a C++ program to find the total salary using inline function.
using namespace std;
inline int Pay(int d, int x)
{
int Sum=0,n;
cout<<"\nTotal Salary = ";
for(n=0;n<d;n++)
{
Sum = Sum + (n+1)*x;
cout<<(n+1)<<"*"<<x<<" + ";
}
return Sum;
}
main(void)
{
int Days,x,TotalPay;
cout<<"\nEnter the no. of days: "; cin>>Days;
cout<<"\nEnter the X : "; cin>>x;
TotalPay = Pay(Days,x);
cout<<" = "<<TotalPay;
return(0);
}
Comments
Leave a comment