Presentation is loading. Please wait.

Presentation is loading. Please wait.

Algorithms and Programming

Similar presentations


Presentation on theme: "Algorithms and Programming"— Presentation transcript:

1 Algorithms and Programming
Ahti Lohk Teaching Assistant in Department of Software Science PhD (in Computer Science)

2 Agenda This presentation answers to the following questions:
What is algorithm and how to represent it? What is programming? What is programming language? What is VBA and for what to use it? How to write the first program (more precisely, we will write an user defined function)? The structure of user defined structure.

3 What is algorithm? „An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate input in a finite amount of time“1. 1Introduction to The Design and Analysis of Algorithms (2012), Anany Levitin

4 Ways to represent algorithms
Some well-known are as follows: Pseudocode Natural language Diagrams (flowcharts) – e.g., activity diagram in UML Programming code The picture originates from here Weekly task 1 (2 points) – please find out some simple examples to these categories (ex. programming code) from internet. Study how to use them/(how do they work) and choose one algorithm and represent it in these 3 categories. Results in MS Word document/LibreOffice Writer. Add references.

5 What is programming? In a narrower meaning: Programming is coding or writing the code in certain programming language. Or, programming is writing instructions to the computer. In a broader meaning: Programming is a diverse process that contains: the analysis of the problem, algorithm and code design, code writing, evaluating and testing.

6 What is a programming language?
The programming language is: artificial language created by man to describe actions which must be done with computer „The programming language is just a tool to express thought (more precisely, an algorithm that represents a solution to any problem) to the computer“. In many cases „it really doesn’t matter much, what programming language you use; your choice generally depends on personal experience/knowledge about the specific programming language.“1 1

7 The most popular programming languages in the world (2016)
IEEE Spectrum TIOBE Index for January 2017

8 The oldest languages in use
Fortran (1957) LIST (1958) COBOL (1959) ... Teacher proposed task 1 (1 point): please find out what kind of programming languages are used in case of the following applications: Amazon, eBay, Facebook, Google, Pinrest, Twitter, Wikipedia, YouTube. At least two languages for every case. Add references.

9 What is VBA? „VBA, which stands for Visual Basic for Applications, is a programming language developed by Microsoft“ VBA is used in Excel (or in other MS Office Application, but also in AutoCAD, ArcGIS, SolidWorks, CorelDraw and WordPerfect) VBA makes possible to operate: different type of data (numbers, text, date values and true-values) and Excel objects (workbooks, worksheets, cells, shapes, diagrams, menu bars, etc.)

10 Visual Basic Editor (VBE) (press Alt+F11) (Environment where to use VBA is called VBE)
Into this window we will write the code  „Figure 2.10 The VBE with significant elements identified.“ Figure originates from book „Excel 2016 Power Programming with VBA“ (Chapter 2) by Michael Alexander and Richard Kusleika (available in Safari)

11 For what to use VBA? Just FYI, it is possible to use VBA for all actions that are possible without VBA. It means, to create new workbooks, add or delete worksheets, charts, shapes, enter values or formulas into cells, etc. Additionally, VBA helps to execute actions impossible implement in Excel only. VBA makes possible to: automate actions (i.e., create lot of documents, charts, data tables, shapes; read information from files, internet, databases) develop new (user defined) functions, See more „Excel VBA Programming For Dummies“, chapter 1. Weekly task 2 (1 point): please find out (does not appear in our two books), in what concrete way VBA is used in Excel (5 cases). Choose only examples you are available to understand. Describe them at least with two-three sentences. Add references.

12 First program (function)
Step 1: Open VBE (Visual Basic Editor) with Alt+F11 Step 2: Add new Module from menu: Insert/Module (Module1 appears into Project window) Step 3: Write program code (function) into code window (to the Module 1 Step 4: Use/apply written function in Excel (result will be 9).

13 The structure of user defined function
Function function_name(parameter1, parameter2, …) ‘Sentence(s) function_name = result End Function Compare it to real case Parameter is a special kind of variable, that is used for passing information (at the moment) from worksheet to user defined function Here, parameters are like input data. Function name and parameter name are defined by user. Variable is a named location in computer memory that maintains values.


Download ppt "Algorithms and Programming"

Similar presentations


Ads by Google