Declare the balance as a global variable

Assignment Help Basic Computer Science
Reference no: EM131427255

Write a C program to simulate deposit/withdraw activities on a banking account. (Hint: you might want to review Lab 3 slides.)

  • Declare the balance as a global variable and initialize it to 600.
  • Write two functions, one for withdraw, the other for deposit. Both withdraw and deposit functions have one parameter, which represent the amount to withdraw or deposit. The functions deduct the balance and add to the balance one dollar at a time, respectively. Therefore, to withdraw 600 thousands, for example, the withdraw function has to execute a loop with 600 thousand iterations. The deposit function works in the same way, in the reverse direction.
  • Create two Posix threads in main(), which call the withdraw and the deposit function respectively.
  • Use pthread_mutex_lock() and pthread_mutex_unlock() functions to ensure mutual exclusion between the two threads. Also make sure to use pthread_join() to wait for the threads to terminate.

Reference no: EM131427255

Questions Cloud

Compute comprehensive income : Classify each transaction as operating, investing, or financing and then prepare an income statement.
Database application development : Two of the most important variables that determine the success of a web form is the form design and form field validation. Think about some web forms you might have completed online recently, such as the FAFSA form to receive financial aid, or you..
Calculate the mean and the standard deviation : Calculate the mean and the standard deviation for the percentage of seats in parliament held by women in these states and interpret your results
Designing secure software : Security cannot be an added afterthought or a half measure. This approach is likely to cause more trouble than doing nothing for system security. Please respond to all of the following prompts:
Declare the balance as a global variable : Write a C program to simulate deposit/withdraw activities on a banking account. (Hint: you might want to review Lab 3 slides.) Declare the balance as a global variable and initialize it to 600.
According to tom bethell, devout religious people tend to : According to Jim Thomas, Eric Hoffman, and Jaydee Hanson, which of the following biofuels sources uses the most water and energy and has the greatest greenhouse gas emissions?According to Jim Thomas, Eric Hoffman, and Jaydee Hanson, pursuing the p..
Describe the infrastructure of cell phone networks : Discussion- Describe the infrastructure of cell phone networks. Explain the importance of IT for nonprofit organizations.
Internet access for security purposes : Take a position on the ethical concerns raised by employees who are upset about organizations monitoring their email or Internet access for security purposes. Assess whether you believe it is fair for an employee to undergo this type of surveillan..
Difference between net profit and comprehensive income : On which financial statement could you find a reconciliation of the beginning and ending balances of comprehensive income (or total recognized income and expense) for a given period of time?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Find an evaluation study from the list of urls

Find an evaluation study from the list of URLs onthis site or one of your own choice.

  Create an employeeexception class

Create an EmployeeException class whose constructor receives a String that consists of an employee's ID and pay rate. Create an Employee class with two fields, idNum and hourlyWage.

  Find the optimal solution to the choice game

With columns Q:U in the Solution sheet, use Solver to find the optimal solution to the choice game. Notice how the choice variables have been constrained. How does Solver do? Explain.

  Write the equation of an ellipse centered at the origin

Describe the result when the foci and center of an ellipse coincide and give the eccentricity of such an ellipse.

  Game changing technology

The Internet is considered a ‘game changing' technology. Discuss at least three reasons why this is true.

  Effective enterprise risk management

The following material may be useful for the completion of this assignment. You may refer to the documents titled "Embracing Enterprise Risk Management: Practical Approaches for Getting Started" and "Developing Key Risk Indicators to Strengthen En..

  Why would the receiver need an extra timer

Why would the receiver need an extra timer if it were responsible for reporting that its advertised window had become nonzero (i.e., if the sender did not probe)?

  Separation between design and implementation

Implement the wallet ADT that you defined in Assignment 1 using doubly linked list. A wallet is  we use to keep our money (paper notes). We want to develop an abstract data type called Wallet that can contain collection of Money.

  Would this tax on soft drinks be considered efficient

Which areas in the graph represent the excess burden (deadweight loss) of the tax?

  Formulate this problem as a shortest path problem

Use the ideas of the paragraphing problem (Example 2.4) to formulate this problem as a shortest path problem.

  Create a controller fsm and connect it to the data path

Use the earlier test bench to simulate the controller/data path system to verify correct behavior.

  What is the time efficiency of nearest-neighbor algorithm

Write pseudocode for the nearest-neighbor algorithm. Assume that its input is given by an n × n intercity distance matrix.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd