120 likes | 230 Views
Computers and Programming. Bina Ramamurthy. 127 Bell Hall bina@cs.buffalo.edu. Introduction. A computer executes the solution designed for a problem. A program expresses the solution in a form that a computer can understand.
E N D
Computers and Programming Bina Ramamurthy 127 Bell Hall bina@cs.buffalo.edu
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.
Topics for discussion • Basic components of a computer • Operating systems • High level language • Processing a program • Software development stages • Example
Basic Components of a digital computer CONTROL INPUT OUTPUT PROCESSOR MEMORY DATA CONTROL
..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.
Operating systems • Provides user interface • Resource management • Security and protection • Provides utility programs and libraries : Editor, math library • Example : unix , MS-DOs, windows-95
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
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.
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.
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.
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