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

  Different document processing applications in more detail

First, make a list of as many different word document applications as you can find. •Second, research at least two different document processing applications in more detail. You cannot use Word as one of your choices. List the advantages and disadvan..

  Hash function uniformly distributes n keys over the tables

If a hash table contains tablesize positions and n records currently occupy the table, the load factor lf is defined as n/tablesize. Suppose a hash function uniformly distributes n keys over the tablesize positions of the table and lf is the load fac..

  Strategies-methodologies to accomplish

Given a requirement to integrate WDAs into an Enterprise Intranet, what are 2 applications that would be candidates for that, and illustrate strategies/methodologies to accomplish that.

  Explain why this might be the case

If you believe a code of ethics impacts an IT professional's behaviour, explain what that impact is and why it occurs. If you do not believe a code of ethics impacts an IT professional's behaviour, explain why this might be the case.

  Describing the features of the different computers

Writea 350- to 700-word summary describing the features of the different computers such as memory, processor, monitor/screen size, operating system, etc. In the summary include the following

  List the components of a typical operating system

List the components of a typical operating system and summarize the role of each in a single phrase.

  Find the volume of a wedge for an arbitrary angle

Two planes cut a right circular cylinder to form a wedge. One plane is perpendicular to the axis of the cylinder and the second makes an angle of θ degrees with the first. (Use r for the radius.)

  Pros and cons of improving information security

Please discuss the pros and cons of improving information security with federal regulations. How well received are the regulations in the affected industries? Have they helped?

  Indicate which ports are not selected by the spanning tree

Given the extended LAN shown in Figure 3.37, indicate which ports are not selected by the spanning tree algorithm.

  Effective user-level thread implementation

What must a kernel provide for an effective user-level thread implementation? Do you have immediate help for this answer?

  Role of it in maintaining corporate compliance

What is the intent of regulatory compliance, and what is the role of IT in maintaining corporate compliance? What can happen to organizations and their senior management if they ignore compliance mandates?

  Draw the hysteresis loop for a soft magnetic material

Draw the hysteresis loop for a soft magnetic material and compare it with the hysteresis loop of hard magnetic material. Give two examples of each.

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