Administrivia - PowerPoint PPT Presentation

About This Presentation
Title:

Administrivia

Description:

Once in a while it prints something on the monitor and you appreciate that ... This prints name of the course (single line comment) ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 18
Provided by: iit1
Category:

less

Transcript and Presenter's Notes

Title: Administrivia


1
Administrivia
  • Lecture hours
  • Monday, Wednesday, Thursday 11-1155am, in L7
  • Come to the class in time
  • Labs
  • 2pm-5pm,
  • Monday A5-A6, Tuesday A7-A8, Wednesday A9-A10,
    Thursday A1-A2, Friday A3-A4
  • The lab starts on Tuesday Jan 2, 2007. Since Jan
    1 is a holiday, the Monday lab shall be held on
    Saturday (Jan 6) during 2-5pm.
  • The lab schedule is given on the course web-page
    (www.iitk.ac.in/esc101
  • Tutorial
  • Tuesday 11-1155am, Tutorial Block 101-110
  • First tutorial on Tuesday Jan 2, 2007.

2
Administrivia
  • Grading
  • Exam 151530
  • Two compulsory lab tests 1015
  • (Note Performance in Lab tests will be taken
    into consideration while deciding about
    borderline cases)
  • Weekly lab sessions 10
  • Tutorials 5
  • Quizzes 10 (extra credit)

3
Administrivia
  • The course web page will have all relevant info
    about the course. You should keep checking the
    web-page for all updates
  • www.iitk.ac.in/esc101
  • Text book
  • Nothing specific your choice
  • Suggestion Java Elements Principles of
    Programming in Java by Bailey and Bailey
  • More references are on the webpage
  • You may also visit past course sites through
    www.iitk.ac.in/esc101

4
What this course is not about
  • This is not a course on programming
  • 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

5
Algorithm
  • The way out is to give a recipe that describes
    how to obtain the right output from any given
    input. We use the term algorithm to denote such
    recipes.
  • Examples algorithm to multiply two arbitrary
    integers, algorithm to find the gcd of two
    integers, etc.
  • For every possible input, an algorithm specifies
    a sequence of steps which when carried out will
    give us the output that corresponds to the input.
  • Although on an input instance an algorithm may
    specify an arbitrary number of steps to be
    carried out, the algorithm itself must be finite.
  • Another property an algorithm must have is that
    each step it specifies must be effective, that
    is, it should be possible for the computing agent
    to carry out the step.

6
Algorithm
  • Consider the problem of computing the product of
    two numbers by repeated addition. Suppose n1 and
    n2 are the two numbers, n2 non-negative, then we
    can find the product by adding n1 n2 times. We
    will assume for this problem that our computing
    agent can add two numbers, but arbitrary number
    of numbers, at any step. With this constraint, an
    algorithm isStep 1. Read in the values of n1
    and n2.Step 2. Initialize result to 0.Step 3.
    While n2 is greater than 0, do Steps 4 and 5Step
    4. Obtain the new value of result as (old value
    of result n1)Step 5. Obtain the new value of
    n2 as (old value of n2 -1)Step 6. Print result.
    (At this point, result n1n2).

7
Flowchart
8
Programs
  • Algorithms are informal objects, these are
    written using natural languages. Although, an
    algorithm is precise enough for a human being to
    follow, electronic computers cannot understand
    these, hence it cannot follow an algorithm to
    compute an output corresponding to a given input.
    It needs the algorithm translated in terms of the
    instructions it is capable to carry out. An
    algorithm, when translated in terms of what a
    computer can comprehend, what we have is a
    program.

9
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

10
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

11
Anatomy of a computer
  • A friend of yours called 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 friend of yours 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

12
Anatomy of a computer
  • A big boss called 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

13
A simple program
  • Lets write a program in English (almost)
  • Want to add five numbers a, b, c, d, e and print
    the result on monitor
  • print (monitor, abcde)
  • 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 16th 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)

14
Printing on monitor
  • / Example of multiline comment
  • This is our first Program /
  • class printcoursename
  • public static void main(String arg)
  • // This prints name of the course (single line
    comment)
  • System.out.println("This course is
    ESc101N")

15
Printing on monitor
  • / Example of multiline comment
  • This is our second Program.
  • Will print the same thing in a different
    way. /
  • class printcoursename
  • public static void main(String arg)
  • // This prints name of the course (single line
    comment)
  • System.out.println("This course
    is ESc101N)

16
Printing numbers
  • class printnumber
  • public static void main (String args)
  • // Notice that I can use args also
  • // because it is a variable name and can be
  • // anything.
  • int var1 // Declaration
  • var1 124 // Operator and expression
  • System.out.println("Value of var1 is
    "var1)

17
Lab 1
  • Learn to use the UNIX environment
  • How to create a file (this where you store your
    programs)
  • How to create and navigate through directory
    (this where you store your files)
  • How to copy files from one directory to another
  • And more www.iitk.ac.in/esc101/linux.pdf
  • Lab is upstairs in CC Your tutor will be there
    in the lab.
Write a Comment
User Comments (0)
About PowerShow.com