EBK CONCEPTS OF PROGRAMMING LANGUAGES
12th Edition
ISBN: 9780135102251
Author: Sebesta
Publisher: VST
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 3, Problem 23PS
Compute the weakest precondition for each of the following assignment statements and postconditions:
- a. a = 2 * (b - 1) - 1 {a > 0}
- b. b = (c + 10) / 3 {b > 6)
- c. a = a + 2 * b - 1{a > 1}
- d. x = 2 * y + x - 1 {x > 11}
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Compute the weakest precondition for each of the
following assignment statements and their
postconditions:
a = 2 * (b - 1)
1 {a > 0}
а.
b.
b =
(c + 10) / 3 {b > 6}
a = a + 2 * b
1 {a > 1}
C.
d.
X = 2 *
y + x
- 1 {x > 11}
int p =5 , q =6;
void foo ( int b , int c ) {
b = 2 * c ;
p = p + c ;
c = 1 + p ;
q = q * 2;
print ( b + c );
}
main () {
foo (p , q );
print p , q ;
}
Explain and print the output of the above code when the parameters to the foo function are passed by value. Explain and print the output of the above code when the parameters to the foo function are passed by reference. Explain and print the output of the above code when the parameters to the foo function are passed by value result. Explain and print the output of the above code when the parameters to the foo function are passed by name.
Book: C++ Programming: From Problem Analysis to Program Design 8th edition, D. S. Malik
In C++
In this programming exercise, you use abstract classes and pure virtual functions to design classes to manipulate various types of accounts. For simplicity, assume that the bank offers three types of accounts: savings, checking, and certificate of deposit, as described next.
Savings accounts: Suppose that the bank offers two types of savings accounts: one that has no minimum balance and a lower interest rate and another that requires a minimum balance and has a higher interest rate.
Checking accounts: Suppose that the bank offers three types of checking accounts: one with a monthly service charge, limited check writing, no minimum balance, and no interest; another with no monthly service charge, a minimum balance requirement, unlimited check writing, and lower interest; and a third with no monthly service charge, a higher minimum requirement, a higher interest rate, and unlimited check…
Chapter 3 Solutions
EBK CONCEPTS OF PROGRAMMING LANGUAGES
Ch. 3 - Prob. 1RQCh. 3 - Prob. 2RQCh. 3 - Prob. 3RQCh. 3 - Prob. 4RQCh. 3 - Prob. 5RQCh. 3 - Prob. 6RQCh. 3 - Prob. 7RQCh. 3 - Prob. 8RQCh. 3 - Prob. 9RQCh. 3 - What is the difference between a synthesized and...
Ch. 3 - Prob. 11RQCh. 3 - Prob. 12RQCh. 3 - Prob. 13RQCh. 3 - Prob. 14RQCh. 3 - Prob. 15RQCh. 3 - Prob. 16RQCh. 3 - Prob. 17RQCh. 3 - Prob. 18RQCh. 3 - Prob. 19RQCh. 3 - Prob. 20RQCh. 3 - Prob. 21RQCh. 3 - What does partial correctness mean for a loop...Ch. 3 - Prob. 23RQCh. 3 - Prob. 24RQCh. 3 - Prob. 25RQCh. 3 - Prob. 26RQCh. 3 - Prob. 27RQCh. 3 - Prob. 28RQCh. 3 - Prob. 29RQCh. 3 - The two mathematical models for language...Ch. 3 - Write EBNF descriptions for the following: a. A...Ch. 3 - Prob. 3PSCh. 3 - Prob. 4PSCh. 3 - Prob. 5PSCh. 3 - Prob. 6PSCh. 3 - Prob. 9PSCh. 3 - Prob. 10PSCh. 3 - Prob. 12PSCh. 3 - Prob. 15PSCh. 3 - Prob. 16PSCh. 3 - Prob. 17PSCh. 3 - Prob. 18PSCh. 3 - Compute the weakest precondition for each of the...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is a recursive functions base case?
Starting Out with C++: Early Objects (9th Edition)
ICA 12-14
Solid objects, such as your desk or a rod of aluminum, can conduct heat. The magnitude of the therma...
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Create a class Ledger that will record the sales for a store. It will have the attributes salean array of doubl...
Java: An Introduction to Problem Solving and Programming (8th Edition)
Assume the variables result, w, x, y, and z are all integers, and that w = 5, x = 4, y = 8, and z = 2. What val...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Ackermanns Function 7. Ackermanns Function is a recursive mathematical algorithm that can be used to test how w...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Circuit Board Profit An electronics company sells circuit boards at a 40 percent profit. If you know the retail...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Redo Programming Exercise 1 by overloading the operators as nonmembers of the classrectangleType. Write a test program that tests various operations on the classrectangleType.arrow_forwarda) Compute the weakest precondition for each of the following assignment statements and post conditions: i) a = 2 * (b + 1) ii)b = 1 {a > 0} 2) / 3 {b > 2} - (c -arrow_forwardExercise 3. Parameter Passing What are the values of y and z at the end of the following block under the assumption that both parameters x are passed: (i) call by value, (ii) call by reference, and (iii) call by value-result. { int y; int z; y = 7; { int f(int x) { X = x+1; y = x; x = x+1; return y }; int g(int x) { y = f(x)+1; x := f(y)+3; return x } }; z := g(y)arrow_forward
- I need the answer as soon as possiblearrow_forwardCourse: Object Oriented programming Lnaguage: C++ You have to solve the Make the program correctly and in 2 hours. kindly Make program correct as much as you can. Question: Develop a polymorphic banking program using the Account hierarchy in which two types of Accounts can be created i.e.Current Account and Saving Account respectively. Each account must have to give the interest to the bank depending upon their account type. A function of name InterestRate() will calculate the interest of account and returns the interest amount. Current Account has annual interest rate of 0.1% of actual amount and SavingAccount will have to pay interest rate of 1.0% of actual amount. Also write a main function for polymorphic calls of the functions. Note: Polymorphic calls for the functions are necessary. Necessary constructor, Destructors, setters, getters and other functions should also be defined.arrow_forwardCompute the weakest precondition for each of the following statements based on their postconditions. b= 2*a + 3*b – 1; a = 2*b {a >= 2} if ( x==4) x = y /2+3; else x = y / 2; {x > 1}arrow_forward
- Exercise 4 Implicit declarations are not good for reliability and writability because misspelled identifier names cannot be detected by the compiler. True or Falsearrow_forwardC++ Question: Make an execution chart like the example below for the code provided. Example chart: An execution chart is a text version of the hierarchy. Indentation is used to indicate thesublevels or calls inside a call. It also contains the data exchange between the components asdesignated in the hierarchy chart. Given below is the execution chart that corresponds to thehierarchy chart of the property tax calculation program1.0 Main()2.0 CalculatePropertyTax()3.0 displayMessage( input string messageToDisplay)3.1 return double getHomeValue()3.2 return boolean checkHomeValue()3.3 return double applyPropertyTax(input double homeValue)3.4 displayPropertyTax(input homeValue)3.5 return Boolean queryMoreData()4.0 displayMessage(input string messageToDisplay)4.1 return char getYesNo()4.2 return char convertCase(input char)3.6 displayErrorMessage() More exlanation: example: 1.0 means it's of depth 1, line 0 then 2.0 means it's one call inside a function (aka it's inside another function)…arrow_forwardQ2) Compute the weakest precondition for the following sequence of assignment statements and its post-condition: p = q 3; k p * 3 + 6; {Q: k <= 12}arrow_forward
- Consider the following C program: int fun(int *i) { *i += 5; return 4; } void main () { int x 3; x = x + fun ( &x) ; } What is the value of x after the assignment statement in main, assuming a. operands are evaluated left to right. b. operands are evaluated right to left.arrow_forwardIn C not C++ please see the images attached for the question and its requirementsarrow_forwardDescription Develop a C program that computes the different roots in a quadratic equation, ax + bX?=0. r= -b ± v (b? – 4ac) , rl is the root when the + is used in the equation and r2 is the root when 2a the – is used. The roots r1 and r2 can only be computed when the discriminant (b - 4ac) is greater than the zero else the quadratic equation does not have any roots and therefore the program should display "no roots". NOTE: sąrt is a built in function in C to extract the roots. The program will prompt to input the values of a, b and c and output the roots r1 and r2 or no roots at all. Check your answer manually. Sample Output if Applicable CT 0:Ruel Lauron\C_Programs\QUAD.exe Enter the value of a:1 Enter the value of b:-3 Enter the value of c:-10 The value of x1 is 5.00 The value of x2 is -2.00arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Structured Chart; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=vdUO-sGA1DA;License: Standard YouTube License, CC-BY
Introduction to Structure Charts; Author: Christopher Kalodikis;https://www.youtube.com/watch?v=QN2bjNplGlQ;License: Standard Youtube License