Welcome to Westonci.ca, your go-to destination for finding answers to all your questions. Join our expert community today! Experience the ease of finding reliable answers to your questions from a vast community of knowledgeable experts. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.

Develop a program that allow to determine through a function the alary to be paid for a aleperon baed on 15% of the ale made. The ale made are undetermined or may vary. - indicate through comment in programming which variable identifier are local, - demontrate the ue of the concept of a global variable, ue a variable identifier called alary to repreent the concept of a global variable. Which are global and the

Sagot :

Here is an example of a program that allows you to determine the salary to be paid to a salesperson based on 15% of the sales made. This program uses the concept of global and local variables, as well as comments to indicate which variables are local.

// Global variable to hold the salary

double salary;

// Function to calculate the salary based on the sales made

double calculateSalary(double sales)

{

   // Local variable to hold the percentage of the sales

   double percentage = 0.15;

   

   // Calculate the salary based on the percentage of the sales

   double salary = sales * percentage;

   

   // Return the calculated salary

   return salary;

}

int main()

{

   // Input the sales made by the salesperson

   double sales = 0;

   cin >> sales;

   

   // Calculate the salary using the calculateSalary function

   salary = calculateSalary(sales);

   

   // Output the calculated salary

   cout << "The salary is: " << salary << endl;

   

   return 0;

}

In this program, the calculateSalary function takes in the sales made by the salesperson as an input and returns the salary to be paid based on 15% of the sales. The calculateSalary function has a local variable called percentage that holds the percentage of the sales to be used to calculate the salary.

The main function is used to input the sales made by the salesperson and call the calculateSalary function to calculate the salary. The salary variable used in the main function is the same global salary variable defined at the beginning of the program, which is used to store the calculated salary.

The comments in the program indicate which variables are local (e.g. percentage) and which are global (e.g. salary). This can help to clarify the scope and purpose of each variable used in the program.