Part 1-Introduction to Computers and C++ Programming
Part 1-Introduction to Computers and C++ Programming
Part 1-Introduction to Computers and C++ Programming
Evaluating
Introduction
• Software
– Instructions to command computer to perform actions and
make decisions
• Hardware
• Structured programming
• Object-oriented programming
What is a Computer?
• Computer
– Device capable of performing computations and making
logical decisions
• Computer programs
– Sets of instructions that control computer’s processing of
data
• Hardware
– Various devices comprising computer
• Keyboard, screen, mouse, disks, memory, CD-ROM,
processing units, …
• Software
– Programs that run on computer
Computer Organization
• History of C
– Evolved from two other programming languages
• BCPL and B
– “Typeless” languages
– Dennis Ritchie (Bell Laboratories)
• Added data typing, other features
– Development language of UNIX
– Hardware independent
• Portable programs
– 1989: ANSI standard
– 1990: ANSI and ISO standard published
• ANSI/ISO 9899: 1990
• History of C++
– Extension of C
– Early 1980s: Bjarne Stroustrup (Bell Laboratories)
– “Spruces up” C
– Provides capabilities for object-oriented programming
• Objects: reusable software components
– Model items in real world
• Object-oriented programs
– Easy to understand, correct and modify
– Hybrid language
• C-like style
• Object-oriented style
• Both
• C++ programs
– Built from pieces called classes and functions
• C++ standard library
– Rich collections of existing classes and functions
• “Building block approach” to creating programs
– “Software reuse”
5.Load ..
..
Primary
6.Execute CPU
Memory
• Input/output
– cin
• Standard input stream
• Normally keyboard
– cout
• Standard output stream
• Normally computer screen
– cerr
• Standard error stream
• Display error messages
• New Application
– C++ language
– Win32 Console Application
– Additional options
• Select Empty project
• Learn How to
– Edit
– Debug
• Breakpoints
– Run
Welcome to C++!
Welcome to C++!
Welcome
to
C++!
Variables
• Variables
– Variable names
• Correspond to actual locations in computer's memory
• Every variable has name, type, size and value
• When new value placed into variable, overwrites previous
value
• Reading variables from memory nondestructive
• Valid identifier
– Series of characters (letters, digits, underscores)
– Cannot begin with digit
– Case sensitive
Memory Concepts
Arithmetic
• Arithmetic calculations
– *
• Multiplication
– /
• Division
• Integer division truncates remainder
– 7 / 5 evaluates to 1
– %
• Modulus operator returns remainder
– 7 % 5 evaluates to 2
Arithmetic
Equality operators
= == x == y x is equal to y
!= x != y x is not equal to y