1 / 24

Hello World 2

Hello World 2. The hidden truth. The Evolution of Programming Languages. Early computers programmed in machine language To calculate wages = rate * hours in machine language: 100100 010001 //Load 100110 010010 //Multiply 100010 010011 //Store.

candie
Download Presentation

Hello World 2

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. Hello World 2 The hidden truth

  2. The Evolution of Programming Languages • Early computers programmed in machine language • To calculate wages = rate * hours in machine language: 100100 010001 //Load 100110 010010 //Multiply 100010 010011 //Store

  3. The Evolution of Programming Languages (cont’d.) • Assembly language instructions are mnemonic • Assembler: translates a program written in assembly language into machine language

  4. The Evolution of Programming Languages (cont’d.) • Using assembly language instructions, wages = rate • hourscan be written as: LOAD rate MULT hour STOR wages

  5. The Evolution of Programming Languages (cont’d.) • High-level languages • Express algorithms at a more abstract level:int wages = rate * hours; • Ex: Basic, FORTRAN, COBOL, Pascal, C, C++, C#, and Java • http://oreilly.com/news/graphics/prog_lang_poster.pdf • http://www.digibarn.com/collections/posters/tongues/tongues.jpg • Current popularitieshttp://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

  6. The Evolution of Programming Languages (cont’d.) • Compiler: translates a program written in a high-level language into machine language

  7. Processing a C++ Program (cont’d.) • To execute a C++ program: • Create a text source program in C++ • Preprocessor directives begin with # and are processed by the preprocessor • Compiler: • Checks that the program obeys the language rules • Translates into machine language (object program)

  8. Processing a C++ Program (cont’d.) • To execute a C++ program (cont'd.): • Linker: • Combines object program with other programs provided by the SDK to create executable code • Library: contains prewritten code you can use

  9. Processing a C++ Program (cont’d.) • To execute a C++ program (cont'd.): • Loader: • Usually operating system • Loads executable program into main memory • The last step is to execute the program

  10. How the code works: • # : preprocessordirective • Instructions to do before compiling • Bring the code from the library iostream into this file

  11. How the code works: • Use all the names that are in the "standard" grouping in my program • Alternative:

  12. How the code works: • ; statement terminator • Ends a "sentence of code"

  13. How the code works: • int main() • The starting point of our program • Program instructions go inside { }

  14. How the code works: • Comment : computer ignores • // : rest of line is comment • /* : everything is comment until */ • /** : special comment – machine readable

  15. Documentation • Every file should have comment like this at top:

  16. How the code works: • cout : console output

  17. How the code works: • cout : console output << "send to output"

  18. How the code works: • cout : console output << "send to output" "Hello" : a string – piece of text

  19. How the code works: • cout : console output << "send to output" "Hello" : a string – piece of text endl : symbol representing "end of line"

  20. How the code works: • return 0 • Program ran successfully • Anything BUT 0 indicates error

  21. Working with numbers • We can output numbers to console: • Can do math using + - / * • Division may give interesting results…

  22. Everything Counts • Indentation & Style matter (to humans) • Spelling & Capitalization matter (to humans & computers)

  23. Errors • Syntax errors : • Errors that prevent code from being built • Runtime errors : • Errors that prevent running program from finishing • Logical errors : • Program is not doing what you meant it to

  24. Exercises: • Write a program that displays: Your NameYour Birthdate • Write a program that displays: • Hints: have to write using / for division, * for multiplication, and ( ) for ordering

More Related