cis 260 computer programming i in c prof. timothy arndt

22
CIS 260 Computer Programming I in C Prof. Timothy Arndt

Post on 22-Dec-2015

225 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: CIS 260 Computer Programming I in C Prof. Timothy Arndt

CIS 260 Computer Programming I in C

Prof. Timothy Arndt

Page 2: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Office location: BU 331

Office hours: 12:30pm – 2:30pm TTH, 7:00pm-8:00pm TH

Office Phone: 687-4779

E-Mail: [email protected]

Page 3: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Course Objectives

Develop algorithmic problem solving skills Understand modern software engineering

techniques for the design of program solutions

Learn the ANSI C programming language

Page 4: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Course Overview

Introduction to computers & programming Problem solving; variables; expressions,

printf Top down design; functions Selection structures; if and switch

statements Repetition and loop statements

Page 5: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Course Overview

Modular programming Data types and operators Arrays Strings Structure and Union Types File Processing Pointers and dynamic memory allocation Stacks, Queues, Binary Trees

Page 6: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Texts

Problem Solving and Program Design in C, Hanly and Koffman, Addison-Wesley, 1996.

Page 7: CIS 260 Computer Programming I in C Prof. Timothy Arndt

History of Electronic Computers

First electronic computer built in late 1930’s by Atanasoff and Berry

First general purpose computer called ENIAC, 1946

These computers used vacuum tubes. Later computers used integrated circuits, LSI, VLSI

Page 8: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Categorization of Computers

Microcomputers Workstations Mainframes Supercomputers Minicomputers Servers

Page 9: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Computer Hardware

Main memory Secondary memory Central processing unit Input devices

– Keyboards

– Mouses

Output devices– Monitors

– Printers

Page 10: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Memory

The memory of a computer is an ordered sequence of storage locations called memory cells

Each memory cell has a unique address The data stored in a cell are called the

contents of the cell A cell may contain diverse types of data -

numbers, characters, or program data

Page 11: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Bytes and bits

A memory cell is a grouping of smaller units called bytes.

A byte is the amount of storage required to store a single character

A bit (binary digit) is the smallest unit a computer can deal with

A bit is either 0 or 1

Page 12: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Storage and Retrieval of Information in Memory To store a value in a memory cell, the

computer sets each bit of the cell to 0 or 1, destroying the previous values

To retrieve a value from a memory cell, the computer copies the contents of the cell to another area

Page 13: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Main memory

Random access memory (RAM) is volatile (data is lost when the computer is turned off).

Read only memory (ROM) is non-volatile and is often used to store the startup instructions of the computer

Cache memory is fast RAM

Page 14: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Secondary Storage Devices

Disk drives are read-write random access devices with files organized in directories and subdirectories– Hard disks– Floppy disks

CD-ROM drives are (usually) read-only random access devices

Tape drives are read-write sequential access devices

Page 15: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Central Processing Unit

Coordinates all computer operations Performs arithmetic and logical operations

on data Stored programs are executed in a cycle of

instruction fetch, instruction decode, data fetch, instruction execute, result store sequences

Page 16: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Input/Output Devices

I/O devices allow us to enter data for a computation and observe the results of the computation

Keyboard Mouse Monitor Printer

Page 17: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Programming Languages

Machine languages are the native languages of the computer and are coded as strings of 0’s and 1’s

Assembly languages substitute symbolic names for strings of 0’s and 1’s

High-Level Language instructions correspond to sequences of assembly language instructions and are easier to read/write

Page 18: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Relationship Between High-Level and Machine Languages In order to be executed by a computer, a

program written in a high-level language (source program) must be translated to machine language

The translator is called a compiler The resulting program is called an object

program

Page 19: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Operating System

The software which controls the operation of a computer is called the operating system

Operating systems may have graphical interfaces (GUIs) command line interfaces (CLIs) or both

Page 20: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Software Development Method

Specify the problem requirements Analyze the problem Design the algorithm to solve the problem Implement the algorithm Test and verify the completed algorithm Maintain and update the program

Page 21: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Case Study: Miles to Kilometers

Analyze the problem Problem input: distance in miles Problem output: distance in kilometers Additional constraints on the solution?

Page 22: CIS 260 Computer Programming I in C Prof. Timothy Arndt

Design

Algorithm – Get the distance in miles– Convert the distance to kilometers– Display the distance in kilometers

Refine the algorithm– The distance in kilometers is 1.609 times the

distance in miles