CIS162AB - C - PowerPoint PPT Presentation

1 / 47
About This Presentation
Title:

CIS162AB - C

Description:

Code is transformed to executable machine language by using special programs ... Sample code: What is the total enrollment in ... zip 4, Y2K, new area code. ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 48
Provided by: JuanMa4
Category:
Tags: cis162ab | area | code

less

Transcript and Presenter's Notes

Title: CIS162AB - C


1
CIS162AB - C
  • Introduction to C
  • CIS105 Review
  • Juan Marquez
  • 01_intro.ppt

2
Two-Part Presentation
  • Part 1
  • CIS105 Review
  • Part 2
  • Introduction to C
  • Compiling Process

3
CIS105 Review (part 1)
  • Hardware
  • Information Processing Cycle
  • Software
  • Programming Languages Generations
  • Software Development Life Cycle

4
A Computer is an electronic device consisting of
hardware.
  • Input Devices
  • Keyboard
  • Mouse
  • Scanner
  • Output Devices
  • Console (Display)
  • Printer
  • Storage Devices
  • Hard drive
  • Zip Disk
  • Flash Disk
  • Internally
  • Central Processing Unit (CPU)
  • CPU Executes Instructions
  • Memory (RAM)

5
Hardware Model
The hardware configuration is used to support the
Information Processing Cycle.
6
Information Processing Cycle
Output from one process can serve as input to
another process.
7
What do we need to operate the hardware and
transform data into information?
Software!
8
Software Two Major Categories
  • Operating System (OS)
  • Application Software

9
Operating System (OS)
  • Software that allocates and monitors computer
    resources including memory allocation, storage,
    and security.
  • Various devices are controlled using system
    programs called drivers.
  • OS ExamplesWindows, UNIX, DOS, VMS, etc.

10
Computer Resources
  • As we go through the course, we will want to
    conceptually understand
  • Memory allocation
  • Storage
  • Well cover storage later, but lets look at
    memory now

11
Main Memory
  • Random Access Memory (RAM).
  • Contents are lost when power is turned off.
  • Measured in bytes.
  • Each byte stores eight bits.
  • BIT Binary Digit (0 1)
  • Each byte is considered a location.
  • Each byte has an address to identify its
    location.
  • Application currently running and the data being
    manipulated must be loaded in memory (RAM).
  • CPU only gets and stores data in RAM.

12
Question
  • What is a nibble?
  • A nibble is half a byte.
  • A byte is 8 bits, and a nibble is 4 bits.

13
Memory Locations
Address 1 Address 2 Address 3 Address 4 Address
5 Etc All consecutive
14
Memory Allocation
Applications
15
Application Software
  • Actual software we use to process raw data into
    information.
  • Application ExamplesWord, Excel, Powerpoint,
    Access, etc.
  • Application software is used in many industries.
  • Business Accounting, Sales
  • Manufacturing Inventory, Labor
  • Education Enrollment, Research
  • Personal Budgeting, School

16
How is software developed, and in particular, how
is application software developed?
By using a programming language!
17
Syntax
  • There are several languages to choose from.
  • Each language has a set of commands that can be
    used.
  • Each language has a set of syntax rules that must
    be followed.
  • Syntax determines many things like how commands
    are entered and how each command should end
    (period, semi-colon, etc).

18
Programming Categories
  • Procedural Programming
  • The programmer must specify in the correct
    sequence what to do and how to do it. Emphasis
    is on the procedures for solution.
  • Programmer controls the processing for users.
  • Procedural techniques are used in all categories.
  • Object Oriented Programming
  • Programming using predefined classes and/or
    programmer defined classes to build programs.
  • Event Programming
  • Usually related to GUI programs.
  • Program reacts to events, like a user clicking on
    a mouse.
  • User has a little more control of the processing,
    because they can decide which text to enter
    first.
  • The program ultimately validates the data, so
    maintains some control.

19
Generations of Programming Language
  • Machine Language (1GL)
  • Low-level (2GL)
  • High-Level (3GL)
  • Query Languages (4GL)
  • Natural Languages (5GL)GL Generation Language

20
Machine Language (1GL)
  • Code is Machine or CPU dependent.
  • So it is not portable.
  • Very cryptic and difficult to code.
  • Sample code
  • 1001 1010 0110 0101 1100 0011
  • Series of binary digits (bits, 0-1).
  • Actual code that can be processed by CPU.

21
Low-level (2GL)
  • Called Assembly.
  • Source code is machine and CPU dependent.
  • Still cryptic and difficult to code.
  • Sample code
  • add P,TL (add price to total)
  • add T,TL (add tax to total)
  • This code is transformed to machine language by a
    program called an assembler.

22
High-level (3GL)
  • Languages are ANSI.
  • American National Standards Institute
  • Machine and CPU independent.
  • Code is more English like.
  • COBOL code
  • Add tax to price giving total. (note period)
  • C, C, and Java Code
  • total tax price
  • Code is transformed to executable machine
    language by using special programs called a
    compiler and linker.

23
Compiler and Linker
  • Compiler
  • Verifies the program is coded with commands it
    recognizes and that the proper syntax was used.
  • Creates an object file (machine language).
  • Linker
  • A program that combines the programs object file
    with object code of standard routines from the
    library.
  • Creates the final executable file.

24
Procedural Languages
  • 1st, 2nd, and 3rd GLs are procedural.
  • The programmer must specify in the correct
    sequence what to do and how to do it.
  • Instructions are in detail and precise.

25
Query Languages (4GL)
  • 4GLs are nonprocedural.
  • Programmers must only specify what to do.
  • The tool figures out how.
  • Many report writers fall into this category.
  • Focus, Datatrieve, and SQL (Structured Query
    Language)
  • There are still syntax rules to follow.
  • Sample SQL Code
  • Select sum(enrolled) from enrollment where course
    CIS163AA

26
Natural Languages (5GL)
  • A computer language that incorporates the
    concepts of knowledge-based systems, expert
    systems, inference engines, and natural language
    processing .
  • Very loose syntax rules.
  • Sample code
  • What is the total enrollment in the Java courses?
  • Must define enrollment and Java (CIS163AA) for
    the product.
  • Some loose definitions include Visual Basic, but
    VB is not a 5GL. It does not meet the definition
    above.

27
Programming
  • Programming is solving a problem using a
    computer.
  • A program is a set of specific instructions for a
    computer to follow.
  • It is a complex process and each program takes on
    a life of its own called SDLC.
  • Software Development Life Cycle

28
SDLC
  • Software Development Life Cycle.
  • There are various methodologies to develop
    programs, but most follow the same process.
  • The actual name for each step in the process may
    vary by vendor.

29
SDLC 3 Phases, 8 Steps
  • Problem Solving Phase
  • Problem Definition
  • Algorithm Design
  • Implementation Phase
  • Build, Test, Install, and Training
  • Support Phase
  • Maintenance
  • Obsolete

30
SDLC - Problem Solving Phase
  • Problem definition (Analysis of the task)Users
    need a screen to do a Sales Order
    Calculation.(qty, price, tax, freight)
  • Algorithm Design (Solution)Desk check with
    common and extreme data.

31
Problem Solving Diagrams
  • Diagrams are independent of programming
    language.
  • Analysis Diagrams / Tools
  • Data Flow Diagram (DFD)
  • Entity Relationship Diagrams (ERD)
  • Functional Descriptions
  • Use Case Diagrams (Object-Oriented)
  • Design Diagrams / Tools
  • Input Output Charts (IPO)
  • Flowcharts - detailed logic
  • Structure charts modules identified
  • Class Diagrams (Object-Oriented)
  • We will see examples of these throughout the
    course.

32
SDLC Implementation Phase
  • Implement or Build (Code the program).
  • Test the program using test data.Actual output
    must match expected results.
  • Deploy or install.May require data conversion or
    hardware upgrades.
  • Training User Documentation.

33
SDLC Support Phase
  • Maintenance change program as needednew tax
    rates, new freight carrier, etc.zip4, Y2K, new
    area code.
  • Obsolete program is discarded due to requiring
    too much effort to corrector new technology (DOS
    to Windows).

34
On Your Homework Assignments
  • I will provide
  • problem definition
  • You will
  • Design Algorithm
  • Build
  • Test

35
C Introduction (part 2)
  • C History (brief)
  • Sample Program
  • Coding Style
  • Some C statements
  • Compile, Link, and Execute
  • Programming Errors

36
History of C
  • C was derived from C.
  • C was developed by ATT Bell Laboratories in the
    late 70s.
  • C was used to write UNIX, which is an Operating
    System (OS).
  • C was then used to develop commercial
    applications to run on UNIX.
  • Eventually C compilers were developed for other
    OSs.

37
Features of C
  • C is a high-level language with features of a
    low-level language.
  • C can directly manipulate the computers memory
    like an OS (consider UNIX history).
  • Can be difficult to understand and use if coded
    cryptic.

38
Introduction to C
  • C was developed to be a better C (1980s).
  • Most C programs compile as C programs, because
    many of the old libraries are still maintained in
    C.
  • C has the capability to do object-oriented
    programming (OOP) through the use of classes.
  • We will learn how to develop classes in the last
    section of this course.

39
Coding Style
  • Block layout indent related code.
  • Make programs easy to read.
  • Use whitespace between commands and sections.
  • Open and closing braces on separate lines .
  • Each command on a separate line.
  • Each statement ends with a semicolon ( ).
  • Declare all variables at the top.

40
Sample C Program
  • //P01 Hello World - Juan Marquez TR 100pm
  • include ltiostreamgt
  • using namespace std
  • void main( )
  • cout ltlt Hello World by Juan Marquez \n\n"

41
Text files to Machine Language
  • C programs are text files .
  • In Windows they have a .cpp extension,P01.cpp.
  • C programs can be written in any text editor,
    such as Notepad or Wordpad.
  • Well be using Microsoft Visual C, which
    includes a text editor.
  • Text files must be converted to machine language.
  • How?
  • By compiling

42
Compiling
Text Editor
P01.cpp
WarningsErrors
Compiler
P01.obj
Library iostream
Linker
P01.exe
43
Three Categories of Errors
  • Syntax Errors and Warnings
  • Logic Errors
  • Run-time Errors
  • Actually are logic errors.

44
Syntax Errors Warnings
  • Detected by compiler, but corrected programmer.
  • Violation of grammar rules.
  • Mistyped commands.
  • Compiler tells you what the error is,or what it
    thinks it is.
  • Compiler tries to tell you where the error
    occurred.
  • Warnings
  • Passes syntax rules but not normally coded this
    way.
  • Programmer should check for possible logic error.

45
Logic Errors
  • Detected and corrected by programmer.
  • Program designed or written incorrectly.
  • Output generated does NOT match expected output.
  • Simple to very complex.
  • Using (multiply) instead of (add)
  • Test, test, text and verify results.
  • This is where programmers earn their money.

46
Run-time Errors
  • Usually discovered by user, but corrected by
    programmer.
  • Program terminates unexpectedly.
  • Error access violation
  • Usually based on a logic error.
  • Divide by zero
  • Users do something programmer didnt expect them
    to do.
  • Processing unexpected input, such as entering
    letters instead of numbers.
  • Users need to document what they were doing when
    the error occurred to help programmer.

47
Summary
  • Hardware Components
  • Information Processing Cycle
  • Software Categories
  • Generations of Programming Languages
  • Software Develop Life Cycle (SDLC)
  • Compiling Process
  • Types of Errors
Write a Comment
User Comments (0)
About PowerShow.com