Computer Programming (CS101) Lecture-02

Slides:



Advertisements
Similar presentations
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Advertisements

CS105 INTRODUCTION TO COMPUTER CONCEPTS INTRO TO PROGRAMMING Instructor: Cuong (Charlie) Pham.
 Introduction to Programming History of programming.
Computer Science Basics CS 216 Fall Operating Systems interface to the hardware for the user and programs The two operating systems that you are.
Number SystemsNumber Systems Modified By: AM. Sihan (Hardware Engineering)
The Binary Machine Modern high-level programming languages are designed to make programming easier. On the other end, the low level, all modern digital.
The Analytical Engine Module 6 Program Translation.
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
Programming Concepts and Languages Chapter 12 – Computers: Understanding Technology, 3 rd edition 1November
ITEC 1011 Introduction to Information Technologies 1. Number Systems Chapt. 2 Location in course textbook.
Prepared By Rama Gaikwad 1. Number Systems. Common Number Systems SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20,
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Lecture 7 How computers process data (Number Systems) PRESENTED BY MD. MAHBUBUL ALAM, PHD 1.
Assembly Language for x86 Processors 7th Edition
Introduction to Computer Science Number Systems. Introduction to Computer Science Common Number Systems SystemBaseSymbols Used by humans? Used in computers?
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
Assembly Language for x86 Processors 7 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and copy this.
Conversion of Number System Conversion Among Bases The possibilities: Hexadecimal DecimalOctal Binary
NUMBER SYSTEMS Prepared By K.Anitha Associate Professor Dept of ECE PVPSIT.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Chapter1: Number Systems
Number Systems Prepared by Department of Preparatory year.
Number System sneha.
Octal to Decimal Hexadecimal DecimalOctal Binary.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 2.
1. Number Systems. Common Number Systems SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20, 1NoYes Octal80, 1, … 7No.
Number Systems. Common Number Systems SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20, 1NoYes Octal80, 1, … 7No.
Computer Number System
Programming 12 : Mr. Jean February 8 th, The plan: Video clip of the day Website Introduction to Hexadecimal Converting from Hexadecimal to Decimal.
1. Number Systems Chapt. 2 Location in course textbook.
ITEC 1011 Introduction to Information Technologies 1. Number Systems Chapt. 2 Location in course textbook.
Prepared By: Md Rezaul Huda Reza University of South Asia Computer Architecture By: Md Rezaul Huda Reza
1. Number Systems. Common Number Systems SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20, 1NoYes Octal80, 1, … 7No.
Alexandria University Faculty of Science Computer Science Department Introduction to Programming C++
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Number Systems. There are 10 kinds of people in the world, those who understand binary and those who don’t.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
Chapter 2- Visual Basic Schneider1 Programming Languages: Machine Language Assembly Language High level Language.
Programming Languages Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
1. Number Systems Chapt. 2. Common Number Systems SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20, 1NoYes Octal80,
Octal to Decimal Decimal Octal Binary Hexadecimal.
1. Number Systems.
NUMBER SYSTEM Prepared by: Engr Zakria.
Number System.
CSCI-235 Micro-Computer Applications
Computer System and Programming
ITE102 – Computer Programming (C++)
CSE 102 Introduction to Computer Engineering
Location in course textbook
Programming Concepts and Languages
Chapter 1 Number Systems & Conversions
Mobile Development Workshop
MMNSS COLLEGE,KOTTIYAM DEPARTMENT OF PHYSICS
1. Number Systems.
Numbering Systems and Arithmetic operations on Hex, binary, and octal
CS105 Introduction to Computer Concepts Intro to programming
Number Systems.
Introduction to Computer Programming
Number Systems created by: S.Shahrukh haider
Binary Addition (1 of 2) Two 1-bit values A B A + B 1
CS 286 Computer Organization and Architecture
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Chapter 6 Programming the basic computer
CS105 Introduction to Computer Concepts Intro to programming
1. Number Systems Chapt. 2.
Introduction to Computer Science
Presentation transcript:

Computer Programming (CS101) Lecture-02 Asst Prof. Rizwan Khan Department of Computer & Engineering rizwan.khan@abesit.in

Introduction to programming

What is a program? How to cook? The algorithm Are you a programmer? Computer Programming 7/22/2019

Pseudocode This is the pseudocode for a game of Monopoly Computer Programming 7/22/2019

Flowcharts Computer Programming 7/22/2019

Flowcharts details Computer Programming 7/22/2019

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 7/22/2019

Source code -> Object code Compiler+linker Fortran, C, Pascal, C++… Interpreter Basic, Perl… Intermediate Java Compiler+linker Fast to execute, but slow to debug Interpreter Slow to execute, but fast to debug (no need to recompile) Intermediate Slow… Computer Programming 7/22/2019

Source code Instructions Data structures Statement, blocks Affectation Operators Loops Tests Subroutines Comments Data structures Variable List Array Hash Pointers Objects Computer Programming 7/22/2019

Source code (2) Statement, blocks Affectation Operator Variable 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 7/22/2019

Source code (3) Pointers Loops Objects Tests Subroutines Comments Reference to region in memory (address) Objects Combination of data and code 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… Computer Programming 7/22/2019

Number Systems

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-positional systems. Our main goal is to discuss the positional number systems, but we also give examples of non-positional systems. Computer Programming 7/22/2019

Common Number Systems System Base Symbols Used by humans? Used in computers? Decimal 10 0, 1, … 9 Yes No Binary 2 0, 1 Octal 8 0, 1, … 7 Hexa- decimal 16 0, 1, … 9, A, B, … F Computer Programming 7/22/2019

Quantities/Counting (1 of 3) Decimal Binary Octal Hexa- decimal 1 2 10 3 11 4 100 5 101 6 110 7 111 Computer Programming 7/22/2019

Quantities/Counting (2 of 3) Decimal Binary Octal Hexa- decimal 8 1000 10 9 1001 11 1010 12 A 1011 13 B 1100 14 C 1101 15 D 1110 16 E 1111 17 F Computer Programming 7/22/2019

Quantities/Counting (3 of 3) Decimal Binary Octal Hexa- decimal 16 10000 20 10 17 10001 21 11 18 10010 22 12 19 10011 23 13 10100 24 14 10101 25 15 10110 26 10111 27 Etc. Computer Programming 7/22/2019

Conversion Among Bases The possibilities: Decimal Octal Binary Hexadecimal Computer Programming 7/22/2019

2510 = 110012 = 318 = 1916 Quick Example Base Computer Programming 7/22/2019

Decimal to Decimal (just for fun) Octal Binary Hexadecimal Next slide… Computer Programming 7/22/2019

Weight 12510 => 5 x 100 = 5 2 x 101 = 20 1 x 102 = 100 125 Base Computer Programming 7/22/2019

Binary to Decimal Decimal Octal Binary Hexadecimal Computer Programming 7/22/2019

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 7/22/2019

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 7/22/2019

Octal to Decimal Decimal Octal Binary Hexadecimal Computer Programming 7/22/2019

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 7/22/2019

Example 7248 => 4 x 80 = 4 2 x 81 = 16 7 x 82 = 448 46810 Computer Programming 7/22/2019

Hexadecimal to Decimal Octal Binary Hexadecimal Computer Programming 7/22/2019

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 7/22/2019

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 7/22/2019

Assignment-02 1.List the differences between Compiler and interpreter. 2.List the differences between low level and high level languages. 3. Decimal Binary Octal Hexa- decimal 100010 403 2CB 1110101 555 1FD 100101 703 11CE 101010 222 1AF Computer Programming 7/22/2019