.

Friday, March 1, 2019

Real Number Essay

1. How do modules help you to reuse label in a program?It reduces the duplication of a code indoors a program by reusing the module that was written once.2. Name and place the two parts that a module definition has in approximately languages. The Header and a BodyFirst the Header indicates a jump pointSecond the Body is a list of statements3. When a module is executing, what happens when the end of the module is reached? Its executed and returned back to the point in the of import program where it was sidetracked from4. What is a local inconsistent? What statements are able to admission price a local protean? A variable is declared in spite of appearance a local module in which it is the only statement indoors a module5. In most languages, where does a local variables scope begin and end? It begins at the variables declaration inwardly a module and it ends at the end of the module in which the variable is declared.6. What is the difference between transeunt an argument b y think of and passing it by reference? By the measure out only a sham of the arguments value is passed and by reference it is passed into a special modifications parameter.7. Why do world(a) variables make a program difficult to debug? It is because the global variables is used throughout all modules and plus they are hard to track.algorithmic program Workbench1. Design a module named timesTen. The module should accept an integer argument. When the module is called, it should presentation the product of its argument multiplied times 10. mental faculty Main () key out timesTen mental faculty timesTen ( integer Value)Declare integerValue get up result = value*10 parade result shoemakers last staff5. Design a module named getNumber, which uses a reference parameter variableto accept an whole number argument. The module should prompt the substance abuser to enter a number and therefore store the input in the reference parameter variable.module getNumber ( integer reviewer valu e)Display Display a number foreplay number block off moduleModule main ()Declare Integer number x = 1Declare documentary number y = 3.4Display (x, ,y)Call changeUS (x, y)Display (x, ,y)End module6. What testament the following pseudocode program display?Declare Integer x = 1Declare Real y = 3.4Display x, , yCall changeUs( x, y)Display x, , yEnd ModuleModule changeUs( Integer a, Real b) sort out a = 0Set b = 0Display a, , bEnd ModuleIt will not display anything since there is nothing within the quotation label7. What will the following pseudocode program display?Module main()Declare Integer x = 1Declare Real y = 3.4Display x, , yCall changeUs( x, y)Display x, , yEnd ModuleModule changeUs( Integer Ref a, Real Ref b)Set a = 0Set b = 0.0Display a, , bEnd ModuleAs outlying(prenominal) as the module you would think that the displays would show something. But in two strings within the quotations marks both are blank to display. program Exercises1. Kilometer Converter Design a modular program that asks the user to enter a distance in kilometers, and then converts that distance to miles. The spiritual rebirth formula is as follows Miles = Kilometers 0.6214 Module main ()Declare Real KilometersDisplay Enter a distance in kilometersInput kilometersCall renewal (kilometers)End ModuleModule conversion (Realvalue)Declare RealmilesSet miles = value*0.6214Display miles2. Sales Tax Program Refactoring Programming Exercise 6 in Chapter 2 was the Sales Tax program. For that exercise you were asked to design a program that calculates and displays the county and state sales tax on a purchase. If you drop already designed that program, refactor it so the subtasks are in modules. If you have not already designed that program, create a modular design for it. Module main ()Declare RealpurchaseDisplay Enter the amount of purchaseInput purchaseCall Module summariseState (purchase)Call Module essenceCounty(purchase)Declare Real totalTaxDeclare Real totalSaleSet total Tax = totalState + totalCountySet totalSale = purchase + totalTaxDisplay Your total state tax is, totalStateDisplay Your total county tax is, totalCountyDisplay Your total tax is, totalTaxDisplay Your total of your sale is, totalSaleEnd ModuleModule totalState (real Ref purchase)Set totalState sales tax = purchase*0.04End ModuleModule totalCounty (real Ref purchase)Set totalCounty sales tax = purchase*0.02End Module

No comments:

Post a Comment