Answer to Question #172234 in C++ for SHIVA

Question #172234

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.


1
Expert's answer
2021-03-16T16:25:32-0400

#include <iostream>

using namespace std;

 

int main()

{

   // declare and initialize variables

   double x, pay = 0.0;

   int day;

 

   cout << "Enter Pay for 1 day: ";

   cin >> x;

 

   for(day = 5; day > 0; day-- )

          pay = pay + x*day;

 

   cout << "Total salary for 5 days: " << pay <<" Rs."<<endl;

   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