Part 1 Write the definition of a function called PayIt that
Part 1. Write the definition of a function called PayIt that takes two arguments a double money and a pointer to a double (*amountPtr). The function should subtract the money from the value at amountPtr, only if there is enough available. The function has a void return type.
Part 2. Write a main function with a function call to PayIt. Declare and initialize any variables needed.
Solution
Dear Asker,
Following is the solution to your question, answer to part 1 and 2 are designated by comment.
#include <cstdlib>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
//solution to part 1
void Payit(double money, double* amountPtr)
{
if (*amountPtr>= money)
{
*amountPtr-=money;
}
}
//solution to part 2
int main()
{
double balance = 200.00;
double moneyToPay = 100;
cout<<\"Before payment, balance is :\"<<balance<<endl;
Payit(moneyToPay,&balance);
cout<<\"After payment, balance is :\"<<balance;
}
