WELCOME To ESC101N: Fundamentals of Computing Instructor: Ajai Jain

Slides:



Advertisements
Similar presentations
1 Administrivia Lecture hours –Monday, Wednesday, Thursday: 11-11:55am, in L7 –Come to the class in time Labs –2pm-5pm, –Monday: A5-A6, Tuesday: A7-A8,
Advertisements

Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
CS 61C L02 Number Representation (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C.
COMP3221: Microprocessors and Embedded Systems--Lecture 1 1 COMP3221: Microprocessors and Embedded Systems Lecture 3: Number Systems (I)
Data Types and Expressions
CS 61C L02 Number Representation (1)Harvey / Wawrzynek Fall 2003 © UCB 8/27/2003  Brian Harvey ( John Wawrzynek  (Warznek) (
CMT Programming Software Applications
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Introduction to Programming with Java, for Beginners
CS 61C L02 Number Representation (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C.
Chapter 2 Data Types, Declarations, and Displays
JavaScript, Third Edition
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Basic Elements of C++ Chapter 2.
Chapter Introduction to Computers and Programming 1.
CENG 311 Machine Representation/Numbers
1 Please switch off your mobile phones. 2 Prolog: The Initiation ET: Hey Alice! What is this on your desk? Alice: That’s a digital computer. ET: Digital.
CPS120: Introduction to Computer Science Lecture 8.
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
Elements of a C++ program 1. Review Algorithms describe how to solve a problem Structured English (pseudo-code) Programs form that can be translated into.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
1 Please switch off your mobile phones. 2 Data Representation Instructor: Mainak Chaudhuri
Computer Systems Organization CS 1428 Foundations of Computer Science.
CSE 1301 Lecture 2 Data Types Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Introduction to Computer Systems and the Java Programming Language.
1 Please switch off your mobile phones. 2 WELCOME To ESC101N: Fundamentals of Computing Instructor: Mainak Chaudhuri
Computer Science 101 Introduction to Programming.
CPS120: Introduction to Computer Science
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
Lecture #5 Introduction to C++
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Primitive Variables.
Fundamental Programming: Fundamental Programming Introduction to C++
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
 Character set is a set of valid characters that a language can recognise.  A character represents any letter, digit or any other sign  Java uses the.
1 homework Due today: hw #1 (mailing list printout) readings to date: chapter 1 and chapter read appendix B (3 pages on DOS) and and.
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
1 CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich
Java Programming, Second Edition Chapter Two Using Data Within a Program.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
1 More data types Character and String –Non-numeric variables –Examples: char orange; String something; –orange and something are variable names –Note.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
CPS120: Introduction to Computer Science Variables and Constants.
Textbook C for Scientists and Engineers © Prentice Hall 1997 Available at NUS CO-OP at S$35.10.
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 06 – Java Datatypes Webpage:
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Topic: Binary Encoding – Part 2
Numbers How does computer understand numbers? Knows only two symbols
Chapter Topics The Basics of a C++ Program Data Types
Java Coding – part 2 David Davenport Computer Eng. Dept.,
BASIC ELEMENTS OF A COMPUTER PROGRAM
Chapter 2 - Introduction to C Programming
Basic Elements of C++.
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Variables and Primative Types
March 2006 Saeid Nooshabadi
Chapter 2 - Introduction to C Programming
Basic Elements of C++ Chapter 2.
IDENTIFIERS CSC 111.
Chapter 2 - Introduction to C Programming
Chapter 2: Java Fundamentals
Understand the interaction between computer hardware and software
Unit 3: Variables in Java
Introduction to C Programming
Presentation transcript:

WELCOME To ESC101N: Fundamentals of Computing Instructor: Ajai Jain

Lecture hours –Monday, Wednesday, Thursday: 8-9am, L17 –Please come to class in time Labs –2pm-5pm, 11 lab sessions –No lab this week Tutorial –Tuesday 8-9 am, Tutorial Block –No tutorial this week

Administrivia Grading - Exam: –Project and/or lab test :20 –Weekly lab sessions: 10 –Two surprise quizzes: 10 Held in tutorial sessions No make up for surprise quizzes (so come to tutorial regularly)

There will be a course web page with all info Text book –Nothing specific: your choice –Suggestion: “Java Elements: Principles of Programming in Java” by Bailey and Bailey –More references are on the webpage Visit past course sites:

What this course is not about This is NOT a course on Java –You will learn how to solve problems with computers: especially the ones that you cannot solve with paper and pencil quickly –The greater part of the lectures will be devoted to the concepts involved in developing a computer algorithm Sequence of steps that solve a problem –Java will be used as a vehicle to demonstrate the concepts Do not expect to become an expert in Java after taking this course

Anatomy of a computer What you see –A monitor, a keyboard, a mouse, a printer … –Input/Output devices –Through these you ask the computer to do something and the computer tells you the results Need a way to convey your commands to the computer (it is really a stupid device which cannot do anything on its own) –Internally A central processing unit and a scratchpad (often called main memory) accomplish the job

Anatomy of a computer Central processing unit does not understand English, not even Java –It only understands two symbols: 0 and 1 –These are called bits (short for binary digits) –You encode your algorithm into a high-level language called Java This is called a program This is harder to understand than English, but easier to understand than a 0-1 encoding How do I encode a program in 0-1? This is used only for storing the program in main memory

Anatomy of a computer A system software compiler translates the program into a binary encoding called an object program –This is almost understandable to the central processing unit (often called a microprocessor) Another software called a linker adds something more to an object program to convert it to an executable –This is understandable to the CPU –But somehow it needs to get started executing

Anatomy of a computer An operating system loads the executable in main memory and hands over the control to the CPU –Now the CPU starts executing your program (essentially the binary executable) –Once in a while it prints something on the monitor and you appreciate that Notice that it is not doing anything on its own, only doing whatever you have asked it to do –At some point the CPU completes the execution and you have all the results

A simple program Let’s write a program in English (almost) –Want to add five numbers a, b, c, d, e and print the result on monitor print (monitor, a+b+c+d+e) – print is used as a function which takes two arguments: where to print and what to print – A binary translation of this could convert each character i.e. p, r, i, n, t, (, m, … into a binary string e.g., p is the 16 th letter of alphabet, so represent it as 16 zeros; put a 1 to mark the end of a character – Now I can design a CPU which can understand this translation and execute my program (caution: this is just an example)

“The Computing Stack” Problem Algorithm Program (HLLs) HLL Compiler/Linker Executable binary Operating System Microarchitecture Circuits Transistors ESC101N HLL=Java Central in CS Hardware/ software interface Hardware

Data Representation Recap Talking to the computer –Numbers Data types –Integer and long integer –Floating-point and double –Character and String –Boolean

Recap Algorithms Programs Compilers: executables (binary: 0 and 1) Operating systems Central processing unit (CPU) and memory

Numbers How does computer understand numbers? –Knows only two symbols –We are mostly familiar with decimal numbers –General number representation in arbitrary base –An algorithm for converting between bases –Special case: base=2 (binary) –Is there a decimal to binary converter inside the computer? Compiler does it –Negative numbers? Two representation conventions: sign-magnitude representation and 2’s complement representation

2’s complement Steps involved in converting decimal to 2’s complement –Decide the number of bits (should be at least 2+integer part of log 2 |N|) –Write the magnitude in binary and append zeros at the front to fill up the remaining bits (this is 2’s complement of the positive number) –Flip all bits (this is 1’s complement of the positive number) –Add 1 to it (this is 2’s complement representation of the negative number)

2’s complement 2’s complement to decimal: –Write down the polynomial expansion in base 2 –Append a negative sign to the leading coefficient Comparison of 2’s complement and sign- magnitude –Range in sign-magnitude with n bits –Range in 2’s complement with n bits –Benefits of 2’s complement in binary arithmetic: makes logic design simpler –All computers and calculators use 2’s complement representation

Variables Anything that stores a value –Symbols made up of characters: A-Z, a-z, 0-9, _, $, … –Called identifiers –Must start with a letter or _ or $ –Examples: dayOfTheWeek, day_of_the_week, dayoftheweek, _dayoftheweek, myname, myName, … –Constants are not variables: 7, 100, 2.5, … –Variables are useful for holding non-constant values

Data types Integer and Long integer –int and long –Called keywords: will learn more keywords –Keywords cannot be used as identifiers –Example: int x; – x is the variable name which we have declared as an integer – x is said to be of type integer – “int” must be written in small characters – This is called syntax of a language – Not following it properly leads to syntax errors

Data types Floating-point and double –Used for representing non-integer numbers –Examples: float pi, run_rate, Average_score; double e, interestRate; – pi, run_rate, Average_score, e, interestRate are variable names – Notice the comma separating the names

Why data types? Why can’t I just use a variable in computation? –Every variable must have a type –Why must it be declared to have a type? –Allocation in the memory –Every variable should get some space in thememory; otherwise how can you use it for computation? –Help the compiler decide how many bits should be reserved for a variable –Observation: compiler must know the data type to size mapping

More data types Character and String –Non-numeric variables –You may be surprised: we will see non- numeric variables in computing –Examples: char orange; String something; – orange and something are variable names – Note the syntax – char is used to store a single symbol e.g. ‘f’, ‘2’, ‘$’, ‘ ‘, … – String is used to store a sequence of symbols e.g. “My name is Tintin.”

Even more data types Boolean –Can take two values only: true or false –true and false are two boolean constants –You may be surprised to see this type Byte –8-bit integer –Example: byte x; –Range of x? Short –16-bit integer –Example: short y;

Constants Integer (int) 1, 234, -56, 0, … Floating-point and double (float, double) 4.5, , 3.14, 2.71, 0.693, 4.5e3, 45000e-1 Character (char) ‘a’, ‘_’, ‘ ‘, ‘A’, ‘m’, ‘$’, … String (String) “Hi there”, “How are you?”, “This is esc101!!” Boolean (boolean) true, false