1 / 18

Procedural Tools and Techniques

Procedural Tools and Techniques. This presentation will explain the different tools and techniques for programming. By Jordan Eagle. Tools. There are different tools for programming that a programmer can use. These tools include Functions, Procedures and Programming Libraries.

marty
Download Presentation

Procedural Tools and Techniques

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Procedural Tools and Techniques This presentation will explain the different tools and techniques for programming. By Jordan Eagle

  2. Tools There are different tools for programming that a programmer can use. These tools include Functions, Procedures and Programming Libraries. A function is a group of statements that is executed by a return value in the program. The procedure does not return any value of the code. The programming libraries is something that the programmer includes as a library. For example, <Include iostream> is a library which the computer recognises to store the code in.

  3. Functions A function is a block of code for a specified purpose, which returns a value. I have made a function called introduction. I have passed through the sentence ‘ Hello. This is my introduction to C++ programming. ’ The function can be used to split up your code. In the screen shots below it shows that I have returned a string from introduction. The function has been returned to my int main function. It has returned because I have put ‘return value’ at the function. Which returns the value of the function to the main program.

  4. Procedure Code A procedure is a block of code that does not return a value to the code. This is my code for a procedure. The void must be above the int main or it will not work. The void procedure returns to value. I am declaring void clears the screen when the user presses a button. I have assigned the screen to be cleared when the user enters number ‘1’. If number ‘1’ is pressed, it will clear the screen and it will go into a separate screen for methods. This is because I have declared a void called ‘method’ which clears the screen when the number is pressed.

  5. Programming Libraries There are a lot of programming libraries which can be used to execute the code. A programming library is prewritten code which allows the programmer to use functions and procedures from the library. For example, the string library allows the programmer to declare a string variables, which is a sequence of characters. Here, I have two program libraries. Iostream and string. The string allows me to include strings, which is a sequence of characters. I can declare those strings and input that into my code. An iostream file is a library which contains the input and output stream, such as the cout and the cin inputsused to interact with the monitor and keyboard. These include libraries contain different functions.

  6. Variables A variable is a type of data which is givenspace in memory. There are different variables that can be used in a program. Types of variables include global, local and static. What a variable holds depends on the data type.

  7. Global The Global variable is when a variable is declared outside of a function or procedure. The global variable can be accessed anywhere in the code and is destroyed when the program ends. Here, I have made a global variable, which equals 10. When I debug my code, it will use the number that has been declared. The global number has now appeared.

  8. Local A local variable is the variable that is inside a particular function in your code. A local variable can have a default value set by the programmer. The variable only exists in the functions curly braces. The variable that the function has been declared in, cannot be accessed in another part of the programmers code. The variable I have declared is now being passed through the int main and will be shown when the code is debugged. The integer ‘localvariable’ will not work if I used that on other part of the code that is outside of the int main. The number ’15’ has now appeared next to the sentence.

  9. Static Static is a variable that is declared, which remains in its memory even when the function or procedure it belongs to is destroyed. It keeps the value it had and in memory when a block of code it is in, is destroyed. The static variable will always keep the same value and is not destroyed after they go out of the code. The variables current value will be called again if its function is called. Here, I have put two variables. I have named the void ‘variable’. Each time I put ‘variable’ in my int main, it will add 1 to the number. I have declared a static number, which is equal to ‘1’. I am then telling the computer to add one to my integer. Since I have put two variables in my int main, the number has been increased by two. My original number was ‘1’ and if I had 3 variables in the int main, it would be increased to number 4.

  10. Techniques There are different techniques that you can perform with programming. These include parameters, returning values and debugging. A parameter is when you pass variables from one part of the code to another. Returning values are returning variables to the calling method. Debugging is when the code is debugged and attempts to make the code work. Debugging allows you to break down your code and identify which part of the code has an error. You can break the code in order to make the computer stop at the line the user has made a break point, which allows the programmer to see where an error has occurred.

  11. Parameters Parameters is passing variables through the code. I have now passed number ‘5’ through from another part of my code to the int main, and it has added both number ‘4’ and ‘5’ to give the number ‘9’. The parameter has passed data from one part of my code to another. Now, the code is now going to add together two different pieces of data from another part of my code. It is now going to get ‘addition’ which = 5 and ‘adding’ which = 4.

  12. Returning Values Returning values allow you to return the value of a variable. Now, the number ‘4’ from the code has been debugged and has came up on my screen. Here I have made a variable called ‘addition’ and declared it as the number ‘4’. I have also said to return that value to my int main. I have also created a separate variable called ‘answer’ and told the computer where to find the number. Here, it knows I want to return it from ‘returning(addition)’ which the computer will go to that piece of code and extract the return value to the int main.

  13. Debugging Debugging debugs your code and allows the programmer to view the code that has been implemented into Microsoft Visual Studio. I am now going to debug this code to check whether it is correct and there are no syntax errors. If there are no problems, it will run the code. This is the debug menu. You can alternatively debug the code by pressing F5.

  14. Using Debug After you click debug, this box will appear. Click yes and your code will be debugged. If there are any syntax errors another option box will appear, stating the problem at the bottom. Alternatively, if your code has syntax errors, it will not run properly. This is an error for my code because I have not included a semi colon at the end of my code, which is a full stop.

  15. Breakpoints You can debug a specific line of code if there is a problem with the code. It allows you to go line by line to identify the problem. When the programmer debugs his code, this is called a break point. This will stop my code at the ‘This will teach you how to do’ line. This is because I am debugging my code. There is also a debugging toolbar which allows you to navigate each line of code. This has stopped my code at this line of code. Now it only reads ‘This tutorial will teach you how to debug your code.’ This is useful for identifying which lines of code are now working, and which lines of code are working. The line of code that is not working, will come up with a syntax error message, which you will know which line of code is the problem, which is quicker than checking all of your code.

  16. Debugging Toolbar When the code has been debugged, a toolbar will appear at the top of the screen, which allows the programmer to navigate each line of code. Control Structures, Conditionals The left white arrow allows your code to be taken back to the previous line of code. The right arrow allows the programmer to be taken to the next line of code, which he can go to each line of code until an error message appears. Now it has went to the next line of code because I have pressed the right arrow.

  17. Control Structures There are many different types of controlled structures which include loops and conditional commands. The loops include fixed and pre and post check. The conditional commands include if and case statements. Fixed Loop This is a loop that is executed a certain amount of times or until a certain condition or value is met. The fixed loop will loop back and execute as many times as required. These types of loops can include for. A for loop is executed a given number of times. For example, In a for loop, it will keep going until it reaches that particular number. Pre-check loop The pre-check loop checks to see whether the code should continue before executing the next part of the code. This also may not execute the next part of the code depending on the condition that has been met. For example, if the code was executed on 0, then there will be a chance that the code will not be executed. This type of loop runs 0 or more times. An example of this is a while conditional statement. This will do something to that particular piece of code. Post-check loop The post check loop is different to the pre-check loop. The post loop runs 1 or more times at least once, whereas the pre-check loop runs 0 or more times. If the programmer doesn’t test the code to determine whether or not for the code to continue after it has been executed. The loop will always be executed at least once in the code, which is different from the pre-check loop as that will not always be executed. An example of the post check is a do-while loop which is a just do statement. It loops while the condition is true.

  18. Conditionals A condition is an operator which can return one of two values depending on the result. If a conditional is true, then it will execute a specific type of code. If the condition is false, then another type of expression will be executed if it has been defined. The condition can be both true and false and assign values to the same variable. If the condition is true, it will run everything in that curly brace, whereas if you condition is false, the programmer can have an else statement for it being false. If the condition is false, then it will print out the code in the else statement.

More Related