1 / 11

Introduction to programming!

Introduction to programming! . This presentation will walk you through some of the basics when it comes to programming. So, what exactly will be covered? Four main and fundamental sections to programming, these are: Selection (For Example how to use Else and Switch)

radley
Télécharger la présentation

Introduction to programming!

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. Introduction to programming! This presentation will walk you through some of the basics when it comes to programming. So, what exactly will be covered? Four main and fundamental sections to programming, these are: Selection (For Example how to use Else and Switch) Iteration (For Example how to use While and For loops) Data Structure (For example, storing data in an Array) Functions, parameters and return values Although these are the main four sections we will be covering, I will first demonstrate how to assemble a project in the Code::blocks IDE. Another IDE such as Visual studio can be used, but for this tutorial we will be sticking to the beginners Code::blocks. ( it is advised you use Code::blocks or another IDE that already has the required GNU compilers installed) Click the following picture to download Code::blocks Aaron Lapper

  2. How to create a project! To create a program in C++ you will first need to create a project to do this follow these step by step instructions: Select the “Create a new project” link that is located on the startup screen. From there select empty project and then click the “Go” button. After this, continue through the Project Creation Wizard giving your project a name and directory. One thing to note is that when you are asked to use a compiler, ensure the GNU GCC Compiler is selected. Aaron Lapper

  3. How to create a project! – Part 2 4. After the project has been created you will need to add a blank file to the project, ensuring it is saved as a CPP file. To do this go to the file option located on the top taskbar and then new > empty file. The important part to note in this section is that you will need to add the .cpp extension to the file so it is recognised as a C++ file. To do this name the file with an appropriate name and then add the .cpp extension to the end of the filename. Ensure the file is saved in the same folder as the created project, however this directory should be selected automatically. Finish: That’s it , you should have a completed project set up, the only thing you need to do now is add the appropriate starting code, this will be explained in the next slide. Aaron Lapper

  4. Starting Code – “Hello world” Line 1:By writing #include <iostream> we are including the library iostream in the project. • Line 5: By writing using namespacestd; we use the standard namespace throughout the whole project. This means in instances such as line 11, we would not need to write std:: for the cout function. • Line 7: By writing intmain()we are declaring the main function. In-between the {} brackets of the main function is where the majority of your code will be located. To show you how to begin to code, I will talk you through the process of outputting “3 , 2, 1, Hello World!” to the console. Line 9:On line 9 we are declaring integers with names. For instance the number 1 is the integer ‘one’. We can refer back to this when we want to output the value by then simply typing ‘one’, this is done in line 11. • Line 10: In addition to this on line 11, Std::coutis used to indicate we are outputting all of the values that follow the <<, simililarystd::endl; indcates we are ending a line. In-between these two sections of code we write the output. In this case it’s “3 2 1 Hello World!”. This is done by writing the already declared integers and then writing the desired text in quotes. • Line 13: Return 0; is then used to return the value 0 and end the program. Aaron Lapper

  5. 3 Important things you need to remember! REMEMBER: • To build and run your program you will press this button. • Always contain your code within the curly brackets. • End every line of code with a semi colon, this is a common error when debugging. Aaron Lapper

  6. This video demonstration will outline: • How to create a project • The use of namespace • Declaring integers • Referring to declared values • Outputting • Returning Values • And Unintentional Error solving Video demonstration of “Hello world”http://www.youtube.com/watch?v=itrMrNejQ1A Aaron Lapper

  7. When working with numbers in programming you can apply a varied array of operators to combine two numerical values in a specific way. The Logical Operators are as follows: Starting Code –Logical Operators Aaron Lapper

  8. This video demonstration will outline: • Use case to select • Use If statements • Make a simple menu • Input into a variable • Assign to a variable • Use namespace More Advance Code – Selection using Cases and Else http://www.youtube.com/watch?v=Gqx-_eAlYok Aaron Lapper

  9. This video demonstration will outline: • Define a while loop • Define a for loop • Iterate values using an incriminator • Print using a loop • Define arguments within a loop More Advance Code – Iteration using For and While loops http://www.youtube.com/watch?v=S-dBpb3JlDk Aaron Lapper

  10. This video demonstration will outline: • How to define an array • How to draw from an array • How to add up totals of an array More Advance Code – Arrayshttps://www.youtube.com/watch?v=ZGTpuisssuw Aaron Lapper

  11. This video demonstration will outline: • Declaring a function • Using a function • Parameters • Returning values from a function More Advance Code – Iteration using For and Functions http://www.youtube.com/watch?v=S-dBpb3JlDk Aaron Lapper

More Related