Programming language concept INSY210.A11 Dr. Feng Liu - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Programming language concept INSY210.A11 Dr. Feng Liu

Description:

Programming language concept INSY210.A11 Dr. Feng Liu Standard streams The standard streams are created automatically and connected to appropriate devices when a ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 36
Provided by: infmMerc
Learn more at: http://infm.mercer.edu
Category:

less

Transcript and Presenter's Notes

Title: Programming language concept INSY210.A11 Dr. Feng Liu


1
Programming language concept
  • INSY210.A11
  • Dr. Feng Liu

2
Lecture1 Introduction to CS and Programming
languages
3
Outline
  • Introduction to Computers
  • Computer System
  • Hardware
  • Software
  • Computer language
  • Programming
  • System development

4
Computer system
5
Hardware
6
Computer Software
7
Relationship
8
Computer system environment
(A)
(B)
  • Personal computer
  • (B) Client Server System
  • (C) Distributed computing

(C)
9
Computer language
10
Computer language
  • Machine Language
  • 010111001011
  • all the components have only two status
  • Switch on 1
  • Switch off 0
  • The only language machine can understand

11
Computer language
  • Symbolic languages (Assembling language) special
    machine order
  • Grace Hopper invent the language
  • entry main
  • pushal (r2)

Assembler
12
Computer language
  • High-level language
  • C /C
  • Java
  • XML
  • VB . etc

Natural Language
13
From high-level lanuage to machine language
  • High-level language like C
  • write and edit code on a text editor (source
    file)
  • Compile with preprocessor translator
  • Link with lib fundtions

Object Module
Object Module
Std Libfunctions
Linker
Compiler
Source file
Object Module
preprocessor
translator
0111001010 1010010010 1010010010 0100101001 001010
1100 1110011010
14
(No Transcript)
15
System development
  • Waterfall model
  • System requirement
  • System analysis define
  • system requirements
  • System goal
  • Analysis
  • Different options
  • Design
  • How to build the system
  • Individual program define
  • Coding
  • Write the program
  • Testing check the satisfaction
  • Maintain keep system works and up to date

Spend more time here Will save the code rewriting
16
Programming process
  • Take the requirement and design of the interface
  • Understand where you program will fit the the
    whole picture
  • Your program take the INPUT and Convert it to a
    desired OUTPUT

17
Tools for developing solution
  • Structure Chart
  • Pseudocode
  • A precise algorithmic description of program
    logic.
  • Flowchart
  • Example
  • Calculate the sqft of your house

18
Structure chart
19
Pseudocode for calculate bathroom
  • Algorithm for calculate bathroom
  • Prompt to user and readin unit price of material
  • Prompt to user and readin number of the bathrooms
  • Set total area of bath to zero
  • While (baths processed lt total number of the
    bathrooms)
  • Prompt user and readin bath length and width
  • Total bath area Total bath area bath length
    bath width
  • Add 1 to baths processed
  • End loop
  • Bath cost total area unit price
  • Return bath cost
  • End of the Algorithm for calculate bathroom
  • Refer to the flowchart for calculate bathroom
    Figure 1-14

20
Testing
  • one set of test data will never enough
  • Two type of testing
  • Blackbox testing
  • Whitebox testing
  • Testing have no end

21
Outline
  • Introduction to the C language
  • Background
  • Structure of C programming
  • First program
  • Identifiers
  • Data types
  • Variables
  • Constant
  • Cin, Cout

22
Structure of C programming
  • Global definition can be access anywhere
  • One program have only one main()
  • Subfunction can be call by another function

Subfuntion
23
First program
  • Pre-compiler directives include header file ltgt
  • Namespace create a space organize the name and
    tell compiler where to find it
  • using namespace std

24
Comments
25
Identifiers
  • Rules
  • AZ, aZ , 0 9, _
  • No start with digital
  • Can not use reserved word (appendix B on the
    book)
  • Example int
  • Convention
  • worker_group
  • workerGroup

26
Data Types
  • Standard data types
  • Derived data types pointer, class, structure,
    array

True 1 false 0
No value, no operation
27
Integer
  • A number without fraction part.
  • How big could be the int is depend on each of the
    machine.
  • Example short int on 16bit
  • signed - 2 15 2 15
  • unsigned 0 2 16

28
Char
  • A char is any value that can be represented in
    computer alphabet.
  • Example
  • Char a
  • Binary 01100001
  • Decimal 97
  • Refer to ASCII table (Appendix App860)

29
Floating
  • Float
  • Byte size 4
  • Number of bits 32
  • Example interest rate 5, or 0.05
  • Double
  • Byte size 8
  • Number of bits 64
  • Example PI 3.1415926

30
Variable
  • Variable declaration
  • Variable type variable identifier
  • int a
  • float a, b, c
  • Variable initialization
  • int a 0
  • float a, b, c 20.0
  • char c1 h

31
Constant
  • Define a constant
  • define SALES_TAX_RATE .825
  • Named constant
  • const float pi 3.14
  • Stored in memory with significant part and
    exponent part
  • Can not be access and modified

32
Character Constant
  • a character a
  • Escape Character (\) used when you need to
    present does not have the graphics associated
    with it.
  • Example
  • \n new line
  • \t tab
  • \ single quote
  • \\ - backslash
  • See more details in pp42

33
String Constants
  • String constant is a sequence of zero or more
    characters enclosed in double quotes.
  • Example
  • hello world!!
  • How to print the following sentence?
  • Good morning! the teacher said.

34
Standard streams
  • The standard streams are created automatically
    and connected to appropriate devices when a
    program starts
  • You need to have std stream declared as
  • include ltinstreamgt
  • Then you can use the iostream in the program,
    otherwise, error!!
  • cout ltlt Hello class!, hope you have fun so
    far!\n
  • cout ltlt See you next time!!

35
Intro to C programming
Write a Comment
User Comments (0)
About PowerShow.com