1 / 31

Computer Programming (CS101) Lecture-02

Computer Programming (CS101) Lecture-02. Asst Prof. Rizwan Khan Department of Computer & Engineering r izwan.khan@abesit.in. Introduction to programming. What is a program?. How to cook? The algorithm Are you a programmer?. Pseudocode. This is the pseudocode for a game of Monopoly.

awilda
Download Presentation

Computer Programming (CS101) Lecture-02

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. Computer Programming(CS101)Lecture-02 Asst Prof.Rizwan Khan Department of Computer & Engineering rizwan.khan@abesit.in

  2. Introduction to programming

  3. What is a program? • How to cook? • The algorithm • Are you a programmer? Computer Programming

  4. Pseudocode • This is the pseudocode for a game of Monopoly Computer Programming

  5. Flowcharts Computer Programming

  6. Flowcharts details Computer Programming

  7. Languages • Low level (processor dependent) • Machine code, assembler • High level: structured, procedural • Fortran, C, Pascal… • High level: object oriented • C++, Java, C#, Perl, Objective-C… • Virtual machines • Java, C#… • Scripting • Perl, Python, JavaScript… Computer Programming

  8. Source code -> Object code • Compiler+linker • Fortran, C, Pascal, C++… • Interpreter • Basic, Perl… • Intermediate • Java • Compiler+linker • Fast to execute, butslow to debug • Interpreter • Slow to execute, butfast to debug (no need to recompile) • Intermediate • Slow… Computer Programming

  9. Source code • Instructions • Statement, blocks • Affectation • Operators • Loops • Tests • Subroutines • Comments • Data structures • Variable • List • Array • Hash • Pointers • Objects Computer Programming

  10. Source code (2) • Statement, blocks • One or more instructions for the processor • Affectation • Change to a variable • Operator • affect one or more variable • + * - / AND OR NOT… • Variable • A region in memory that can be modified • Exists in different types • Scalar, char, numeric, boolean • List, array • Hash • Combination->data structure Computer Programming

  11. Source code (3) • Loops • Allow the computer to repeat blocks • Tests • Decide what to do • Subroutines • Programs frequently called (functions) • Comments • The most important lines of the source code… • Pointers • Reference to region in memory (address) • Objects • Combination of data and code Computer Programming

  12. Number Systems

  13. 2-1 INTRODUCTION A number system defines how a number can be represented using distinct symbols. A number can be represented differently in different systems. For example, the two numbers (2A)16 and (52)8 both refer to the same quantity, (42)10, but their representations are different. Several number systems have been used in the past and can be categorized into two groups: positional and non-positionalsystems. Our main goal is to discuss the positional number systems, but we also give examples of non-positional systems. Computer Programming

  14. Common Number Systems Computer Programming

  15. Quantities/Counting (1 of 3) Computer Programming

  16. Quantities/Counting (2 of 3) Computer Programming

  17. Quantities/Counting (3 of 3) Etc. Computer Programming

  18. Conversion Among Bases • The possibilities: Decimal Octal Binary Hexadecimal Computer Programming

  19. Quick Example 2510 = 110012 = 318 = 1916 Base Computer Programming

  20. Decimal to Decimal (just for fun) Decimal Octal Binary Hexadecimal Next slide… Computer Programming

  21. Weight 12510 => 5 x 100 = 5 2 x 101 = 20 1 x 102 = 100 125 Base Computer Programming

  22. Binary to Decimal Decimal Octal Binary Hexadecimal Computer Programming

  23. Binary to Decimal • Technique • Multiply each bit by 2n, where n is the “weight” of the bit • The weight is the position of the bit, starting from 0 on the right • Add the results Computer Programming

  24. Example Bit “0” 1010112 => 1 x 20 = 1 1 x 21 = 2 0 x 22 = 0 1 x 23 = 8 0 x 24 = 0 1 x 25 = 32 4310 Computer Programming

  25. Octal to Decimal Decimal Octal Binary Hexadecimal Computer Programming

  26. Octal to Decimal • Technique • Multiply each bit by 8n, where n is the “weight” of the bit • The weight is the position of the bit, starting from 0 on the right • Add the results Computer Programming

  27. Example 7248 => 4 x 80 = 4 2 x 81 = 16 7 x 82 = 448 46810 Computer Programming

  28. Hexadecimal to Decimal Decimal Octal Binary Hexadecimal Computer Programming

  29. Hexadecimal to Decimal • Technique • Multiply each bit by 16n, where n is the “weight” of the bit • The weight is the position of the bit, starting from 0 on the right • Add the results Computer Programming

  30. Example ABC16 => C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560 274810 Computer Programming

  31. Assignment-02 • 1.List the differences between Compiler and interpreter. • 2.List the differences between low level and high level languages. • 3. Computer Programming

More Related