Answer to Question #178314 in C++ for Varshini

Question #178314

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.


1
Expert's answer
2021-04-05T20:39:02-0400
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);
 }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS