Wednesday, December 11, 2019

Procedures, Parameters ; Sub

Procedures, Parameters ; Sub-programs Essay Procedures, Parameters Sub-ProgramsIn any modern programming language, procedures play a vital role in theconstruction of any new software. These days, procedures are used instead ofthe old constructs of GOTO and GOSUB, which have since become obsolete. Procedures provide a number of important features for the modern softwareengineer:-Programs are easier to write. Procedures save a large amount of time duringsoftware development as the programmer only needs to code a procedure once, butcan use it a number of times. Procedures are especially useful in recursivealgorithms where the same piece of code has to be executed over and over again. The use of procedures allows a large and complex program to be broken up into anumber of much smaller parts, each accomplished by a procedure. Procedures alsoprovide a form of abstraction as all the programmer has to do is know how tocall a procedure and what it does, not how it accomplishes the task. Programs are easier to read. Procedures help to make programs shorter, and thuseasier to read, by replacing long sequences of statements with one simpleprocedure call. By choosing goo procedure names, even the names of theprocedures help to document the program and make it easier to understand. Programs are easier to modify. When repeated actions are replaced by oneprocedure call, it becomes much easier to modify the code at a later stage, andalso correct any errors. By building up the program in a modular fashion viaprocedures it becomes much easier to update and replace sections of the programat a later date, if all the code for the specific section is in a particularmodule. Programs take less time to compile. Replacing a sequence of statements withonce simple procedure call usually reduces the compilation time of the program,so long as the program contains more than one reference to the procedure!Object programs require less memory. Procedures reduce the memory consumptionof the program in two ways. Firstly they reduce code duplication as the codeonly needs to be stored once, but the procedure can be called many times. Secondly, procedures allow more efficient storage of data, because storage for aprocedures variables is allocated when the procedure is called and deallocatedwhen it returns. We can divide procedures into two groups:-Function procedures, are procedures which compute a single value and whose callsappear in expressionsFor example, the procedure ABS is a function procedure, when given a number x,ABS computes the absolute value of x; a call of ABS appears in an expression,representing the value that ABS computes. Proper procedures, are procedures whose calls are statementsFor example, the procedure INC is a proper procedure. A call of INC is astatement; executing INC changes the value stored in a variable. Procedures have only one real disadvantage: Executing a procedure requiresextra time because of the extra work that must be done both when the procedureis called, and when it returns. Most of the time however, the advantages of using procedures heavily outweighthis minor disadvantage. Most procedures depend on data that varies from one call to the next, and forthis reason, Modula-2 allows a procedure heading to include a list ofidentifiers that represent variables or expressions to supply when calling theprocedure. The programmer can use these identifiers, known as formalparameters, in the body of the procedure in the same fashion as ordinaryvariables. A call of a procedure with parameters must include a list of actual parameters. The number of actual parameters must be the same as the number of formalparameters. Correspondence between the actual and formal parameters is byposition, so the first actual parameter corresponds to the first formalparameter, the second actual parameter corresponds to the second formalparameter, and so on. The type of each actual parameter must match the type ofthe corresponding formal parameter. .ue62138a32485acd2d68ea76d9e27ca10 , .ue62138a32485acd2d68ea76d9e27ca10 .postImageUrl , .ue62138a32485acd2d68ea76d9e27ca10 .centered-text-area { min-height: 80px; position: relative; } .ue62138a32485acd2d68ea76d9e27ca10 , .ue62138a32485acd2d68ea76d9e27ca10:hover , .ue62138a32485acd2d68ea76d9e27ca10:visited , .ue62138a32485acd2d68ea76d9e27ca10:active { border:0!important; } .ue62138a32485acd2d68ea76d9e27ca10 .clearfix:after { content: ""; display: table; clear: both; } .ue62138a32485acd2d68ea76d9e27ca10 { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #95A5A6; } .ue62138a32485acd2d68ea76d9e27ca10:active , .ue62138a32485acd2d68ea76d9e27ca10:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #2C3E50; } .ue62138a32485acd2d68ea76d9e27ca10 .centered-text-area { width: 100%; position: relative ; } .ue62138a32485acd2d68ea76d9e27ca10 .ctaText { border-bottom: 0 solid #fff; color: #2980B9; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .ue62138a32485acd2d68ea76d9e27ca10 .postTitle { color: #FFFFFF; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .ue62138a32485acd2d68ea76d9e27ca10 .ctaButton { background-color: #7F8C8D!important; color: #2980B9; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://artscolumbia.org/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .ue62138a32485acd2d68ea76d9e27ca10:hover .ctaButton { background-color: #34495E!important; } .ue62138a32485acd2d68ea76d9e27ca10 .centered-text { display: table; height: 80px; padding-left : 18px; top: 0; } .ue62138a32485acd2d68ea76d9e27ca10 .ue62138a32485acd2d68ea76d9e27ca10-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .ue62138a32485acd2d68ea76d9e27ca10:after { content: ""; display: block; clear: both; } READ: Relationship of Demetrius and Helena EssayModula-2 provides to kinds of formal parameters:-Variable parameters. In a procedure heading, if the reserved word VAR precedesa formal parameter, then it is a variable parameter. Any changes made to avariable parameter within the body of the procedure also affect thecorresponding actual parameter in the main body of the program. Value parameters. If the reserved word VAR does not precede a formal parameterthen it is a value parameter. If a formal parameter is a value parameter, thecorresponding actual parameter is protected from change, no matter what changesare made to the corresponding parameter in the procedure. To sum up, variable parameters

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.