B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall [email protected].

12
B.Ramamurthy 08/29/22 Computers and Programming Bina Ramamurthy 127 Bell Hall [email protected]

Transcript of B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall [email protected].

Page 1: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 1

Computers and Programming

Bina Ramamurthy

127 Bell [email protected]

Page 2: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 2

Introduction

A computer executes the solution designed for a problem. A program expresses the solution in a form that a computer can understand.

In this discussion we will look at the basic components of a computer, the programming environment, the system support, and program development phases.

Page 3: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 3

Topics for discussion

Basic components of a computer Operating systems High level language Processing a program Software development stages Example

Page 4: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 4

Basic Components of a digital computer

INPUT PROCESSOR OUTPUT

CONTROL

MEMORYDATA

CONTROL

Page 5: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 5

..Components ...

Processor = Arithmetic Logic Unit (ALU) ALU + Control = CPU = Central Processing Unit Ex: PowerPc 604, Intel Pentium, Motorola 68xxx Ex: Input : Mouse Output : laser printer Memory : main memory (RAM) Secondary memory : Floppy disk, hard disk.

Page 6: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 6

Operating systems

Provides user interface Resource management Security and protection Provides utility programs and libraries :

Editor, math library Example : unix , MS-DOs, windows-95

Page 7: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 7

High level language

The hardware underlying a computer communicates and computes in binary code called machine code.

But in order for the humans to effectively communicate the solutions to a computer we need a language that is closer to human language : High Level language (HLL). ex: C++

Problem : HLL -->machine code Solution: A translation mechanism : Compiler or

an interpreter

Page 8: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 8

Page 9: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 9

Steps in software development Problem analysis

– Clear understanding of the problem

– identify problem’s input, output, requirements and constraints.

Solution design– Class design : Identify the classes of objects required

by the problem and draw relationship among these.

– Algorithm design: Stepwise solution to carry out the functionality of the classes.

Page 10: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 10

Steps in software development (contd.)

Documentation– Provide information for use and maintenance of the software.

Provide an example that gives input and output. Implementation

– Code the algorithms into a programs using a HLL. Debugging

– Compile and execute the software. Remove any errors. Testing

– Execute with various test data and make sure the software works as expected.

Page 11: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 11

Example (non-computer problem)

Problem 1: You are on your way to visit a friend in Chicago. You are driving in downtown Chicago and are lost. Solve this problem.

Page 12: B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu.

B.Ramamurthy 04/20/23 12

Example (computer problem) Problem 2: Count the number of times the letter ‘a’ occurs in a

piece of text. Solution: 1. Initialize Acounter = 0; // Assignment - memory

2. Input a character from input. //input

3. If it is an “a” then // selection

Increment Acounter; // arithmetic - memory

4. Repeat steps 2 - 3 until end of input. //repetition

5. Output Acounter. // output

6. Exit