SlideShare ist ein Scribd-Unternehmen logo
 
Chapter 1 Introduction to Computers and  C++ Programming
Overview 1.1  Computer Systems  1.2  Programming and Problem Solving 1.3  Introduction to C++ 1.4  Testing and Debugging Slide 1-
1.1 Computer Systems
Computer Systems A  computer program is… A set of instructions for a computer to follow Computer software is … The collection of programs used by a computer Includes: Editors Translators System Managers Slide 1-
Hardware Three main classes of computers PCs  (Personal Computer) Relatively small used by one person at a time Workstation Larger and more powerful than a PC Mainframe Still larger Requires support staff Shared by multiple users Slide 1-
Networks A number of computers connected to  share resources Share printers and other devices Share information Slide 1-
Computer Organization Five main components Input devices Allows communication to the computer Output devices Allows communication to the user Processor (CPU) Main memory Memory locations containing the running program Secondary memory Permanent record of data often on a disk Slide 1-  Display 1.1
Computer Memory Main Memory Long list of memory locations Each contains zeros and ones Can change during program execution Binary Digit or Bit A digit that can only be zero or one Byte Each memory location has eight bits Address  Number that identifies a memory location Slide 1-
Larger Data Items Some data is too large for a single byte Most integers and real numbers are too large Address refers to the first byte  Next few consecutive bytes can store the  additional bits for larger data Slide 1-  Display 1.2
Data or Code? ‘ A’ may look like 01000001 65 may look like  01000001 An instruction may look like 01000001 How does the computer know the meaning of 01000001? Interpretation depends on the current instruction Programmers rarely need to be concerned with  this problem. Reason as if memory locations contain letters and  numbers rather than zeroes and ones Slide 1-
Secondary Memory Main memory stores instructions and  data while a program is running. Secondary memory Stores instructions and data between sessions A file stores data or instructions in  secondary memory Slide 1-
Secondary Memory Media A computer might have any of these types of secondary memory Hard disk Fast Fixed in the computer and not normally removed Floppy disk Slow Easily shared with other computers Compact disk Slower than hard disks Easily shared with other computers Can be read only or re-writable Slide 1-
Memory Access Random Access  Usually called RAM Computer can directly access any memory location Sequential Access Data is generally found by searching through other items first More common in secondary memory Slide 1-
The Processor Typically called the CPU Central Processing Unit Follows program instructions  Typical capabilities of CPU include:   add subtract multiply divide move data from location to location Slide 1-
Computer Software The operating system  Allows us to communicate with the computer Is a program  Allocates the computer’s resources Responds to user requests to run other programs Common operating systems include… UNIX  Linux  DOS Windows Macintosh VMS Slide 1-
Computer Input Computer input consists of  A program Some data Slide 1-  Display 1.3
High-level Languages Common programming languages include …   C  C++  Java  Pascal  Visual Basic  FORTRAN  Perl  COBOL  Lisp  Scheme  Ada   C#  Python These high – level languages  Resemble human languages Are designed to be easy to read and write Use more complicated instructions than   the CPU can follow Must be translated to zeros and ones for the CPU  to execute a program Slide 1-
Low-level Languages An assembly language command  such as   ADD  X  Y  Z might mean add the values found at x and y  in memory, and store the result in location z. Assembly language must be translated to  machine language (zeros and ones)    0110  1001  1010  1011 The CPU can follow machine language Slide 1-
Compilers Translate high-level language to  machine language Source code The original program in a high level language Object code The translated version in machine language Slide 1-  Display 1.4
Linkers Some programs we use are already compiled Their object code is available for us to use For example:  Input and output routines A Linker combines The object code for the programs we write    and The object code for the pre-compiled routines   into The machine language program the CPU can run Slide 1-  Display 1.5
History Note First programmable computer Designed by Charles Babbage Began work in 1822 Not completed in Babbage’s life time First programmer Ada Augusta, Countess of Lovelace Colleague of Babbage Slide 1-
Section 1.1 Conclusion Can you… List the five main components of a computer? List the data for a program that adds two numbers? Describe the work of a compiler? Define source code?  Define object code? Describe the purpose of the operating system? Slide 1-
1.2 Programming and Problem-Solving
Algorithms  Algorithm A sequence of precise instructions that leads to a solution Program An algorithm expressed in a language the  computer can understand Slide 1-  Display 1.6
Program Design Programming is a creative process No complete set of rules for creating a program Program Design Process Problem Solving Phase Result is an algorithm that solves the problem Implementation Phase Result is the algorithm translated into a programming language Slide 1-
Problem Solving Phase Be certain the task is completely specified What is the input?  What information is in the output?  How is the output organized? Develop the algorithm before implementation Experience shows this saves time in getting your program to run. Test the algorithm for correctness Slide 1-
Implementation Phase Translate the algorithm into a programming  language Easier as you gain experience with the language Compile the source code Locates errors in using the programming language Run the program on sample data Verify correctness of results  Results may require modification of  the algorithm and program Slide 1-  Display 1.7
Object Oriented Programming Abbreviated OOP Used for many modern programs Program is viewed as interacting objects Each object contains algorithms to describe  its behavior Program design phase involves designing  objects and their algorithms Slide 1-
OOP Characteristics Encapsulation Information hiding Objects contain their own data and algorithms Inheritance Writing reusable code Objects can inherit characteristics from other objects Polymorphism A single name can have multiple meanings depending  on its context Slide 1-
Software Life Cycle Analysis and specification of the task  (problem definition) Design of the software  (object and algorithm design) Implementation (coding) Maintenance and evolution of the system Obsolescence Slide 1-
Section 1.2 Conclusion Can you… Describe the first step to take when creating  a program? List the two main phases of the program  design process? Explain the importance of the problem-solving phase? List the steps in the software life cycle? Slide 1-
1.3 Introduction to C++
Introduction to C++ Where did C++ come from? Derived from the C language C was derived from the B language B was derived from the BCPL language Why the ‘++’? ++ is an operator in C++ and results in a cute pun Slide 1-
C++ History C developed by Dennis Ritchie at AT&T Bell Labs in the 1970s. Used to maintain UNIX systems Many commercial applications written in c C++ developed by Bjarne Stroustrup at AT&T Bell Labs in the 1980s. Overcame several shortcomings of C Incorporated object oriented programming C remains a subset of C++ Slide 1-
A Sample C++ Program A simple C++ program begins this way #include <iostream> using namespace std; int main() { And ends this way   return 0; } Slide 1-  Display 1.8
Explanation of code (1/5) Variable declaration line  int number_of_pods, peas_per_pod, total_peas; Identifies names of three variables to name numbers int means that the variables represent integers Slide 1-
Explanation of code (2/5) Program statement cout << “Press return after entering a number.”; cout (see-out) used for output to the monitor “ <<“  inserts “Press…a number.” in the data bound for the monitor Think of cout as a name for the monitor “ <<“ points to where the data is to end up ‘ ’  causes a new line to be started on the monitor Slide 1-
Explanation of code (3/5) Program statement cin >> number_of_pods; cin (see-in) used for input from the keyboard “ >>” extracts data from the keyboard  Think of cin as a name for the keyboard “ >>” points from the keyboard to a variable where the data  is stored Slide 1-
Explanation of code (4/5) Program statement   total_peas = number_of_pods * peas_per_pod; Performs a computation ‘ *’ is used for multiplication ‘ =‘ causes total_peas to get a new value based on the calculation shown on the right of the equal sign Slide 1-
Explanation of code (5/5) Program statement   cout << number_of_pods; Sends the value of variable number_of_pods to the monitor Slide 1-
Program Layout (1/3) Compiler accepts almost any pattern of line breaks and indentation Programmers format programs so they  are easy to read Place opening brace ‘{‘ and closing brace ‘}’  on a line by themselves Indent statements  Use only one statement per line Slide 1-
Program Layout (2/3) Variables are declared before they are used Typically variables are declared at the beginning of  the program Statements (not always lines) end with a semi-colon Include Directives #include <iostream> Tells compiler where to find information about items  used in the program iostream is a library containing definitions of cin and cout Slide 1-
Program Layout (3/3) using namespace std; Tells the compiler to use names in iostream in a “standard” way   To begin the main function of the program int main()   {  To end the main function   return 0;   } Main function ends with a return statement Slide 1-
Running a C++ Program C++ source code is written with a text  editor The compiler on your system converts  source code to object code. The linker combines all the object code into an executable program. Slide 1-
Run a Program  Obtain code in Display 1.10 Compile the code Fix any errors the compiler indicates and  re-compile the code Run the program  Now you know how to run a program on  your system Slide 1-  Display 1.10
Section 1.3 Conclusion Can you… Describe the output of this line? cout << “C++ is easy to understand.”; Explain what this line does? cin >> peas_per_pod; Explain this?  #include <iostream> Slide 1-
1.4 Testing and Debugging
Testing and Debugging Bug A mistake in a program Debugging Eliminating mistakes in programs Term used when a moth caused a failed relay on the Harvard Mark 1 computer.  Grace Hopper  and other programmers taped the moth in logbook  stating:    “First actual case of a bug being found.” Slide 1-
Program Errors Syntax errors Violation of the grammar rules of the language Discovered by the compiler Error messages may not always show correct location of  errors Run-time errors Error conditions detected by the computer at run-time Logic errors Errors in the program’s algorithm Most difficult to diagnose Computer does not recognize an error Slide 1-
Section 1-4 Conclusion Can you… Describe the three kinds of program errors? Tell what kind of errors the compiler catches? What kind of error is produced if you forget  a  punctuation symbol such as a semi-colon? Tell what type of error is produced when a program  runs but produces incorrect results? Slide 1-
Chapter 1 -- End Slide 1-
Display 1.1 Slide 1-  Back Next
Display 1.2 Slide 1-  Back Next
Display 1.3 Slide 1-  Back Next
Display 1.4 Slide 1-  Back Next
Display 1.5 Slide 1-  Back Next
Display 1.6 Slide 1-  Back Next
Display 1.7 Slide 1-  Back Next
Display 1.8 Slide 1-  Next Back
Display 1.9 Slide 1-  Back Next
Display 1.10 Slide 1-  Next Back

Weitere ähnliche Inhalte

Was ist angesagt?

Unit 1
Unit 1Unit 1
Unit 1
TPLatchoumi
 
Lecture1 compilers
Lecture1 compilersLecture1 compilers
Lecture1 compilers
Aftab Ahmad
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
Preeti Katiyar
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
Dr. C.V. Suresh Babu
 
Programming Languages / Translators
Programming Languages / TranslatorsProgramming Languages / Translators
Programming Languages / Translators
Project Student
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
kazi_aihtesham
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
Sangheethaa Sukumaran
 
Compiler design
Compiler designCompiler design
Compiler design
Thakur Ganeshsingh Thakur
 
Introduction to Compiler
Introduction to CompilerIntroduction to Compiler
Introduction to Compiler
Radhakrishnan Chinnusamy
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
Ibrahimcommunication Al Ani
 
df
dfdf
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7
Shipra Swati
 
Lec 01 basic concepts
Lec 01 basic conceptsLec 01 basic concepts
Lec 01 basic concepts
Abdul Khan
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
baabtra.com - No. 1 supplier of quality freshers
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl Translator
Cma Mohd
 
Assembly language
Assembly languageAssembly language
Assembly language
shashank puthran
 
COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis: COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis:
Jyothishmathi Institute of Technology and Science Karimnagar
 
C++ programming languages lectures
C++ programming languages lectures C++ programming languages lectures
C++ programming languages lectures
jabirMemon
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
Sarmad Ali
 
13 A Programing Languages (IT) Lecture Slide
13 A Programing Languages (IT) Lecture Slide13 A Programing Languages (IT) Lecture Slide
13 A Programing Languages (IT) Lecture Slide
Muhammad Talha Zaroon
 

Was ist angesagt? (20)

Unit 1
Unit 1Unit 1
Unit 1
 
Lecture1 compilers
Lecture1 compilersLecture1 compilers
Lecture1 compilers
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Programming Languages / Translators
Programming Languages / TranslatorsProgramming Languages / Translators
Programming Languages / Translators
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
Compiler design
Compiler designCompiler design
Compiler design
 
Introduction to Compiler
Introduction to CompilerIntroduction to Compiler
Introduction to Compiler
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
df
dfdf
df
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7
 
Lec 01 basic concepts
Lec 01 basic conceptsLec 01 basic concepts
Lec 01 basic concepts
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl Translator
 
Assembly language
Assembly languageAssembly language
Assembly language
 
COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis: COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis:
 
C++ programming languages lectures
C++ programming languages lectures C++ programming languages lectures
C++ programming languages lectures
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
13 A Programing Languages (IT) Lecture Slide
13 A Programing Languages (IT) Lecture Slide13 A Programing Languages (IT) Lecture Slide
13 A Programing Languages (IT) Lecture Slide
 

Andere mochten auch

Savitch Ch 15
Savitch Ch 15Savitch Ch 15
Savitch Ch 15
Terry Yoast
 
Savitch Ch 07
Savitch Ch 07Savitch Ch 07
Savitch Ch 07
Terry Yoast
 
Savitch Ch 12
Savitch Ch 12Savitch Ch 12
Savitch Ch 12
Terry Yoast
 
Savitch Ch 08
Savitch Ch 08Savitch Ch 08
Savitch Ch 08
Terry Yoast
 
Savitch Ch 17
Savitch Ch 17Savitch Ch 17
Savitch Ch 17
Terry Yoast
 
Savitch ch 07
Savitch ch 07Savitch ch 07
Savitch ch 07
Terry Yoast
 
Cs1123 12 structures
Cs1123 12 structuresCs1123 12 structures
Cs1123 12 structures
TAlha MAlik
 
Eee3420 lecture06 rev2011
Eee3420 lecture06 rev2011Eee3420 lecture06 rev2011
Eee3420 lecture06 rev2011
benson215
 
Structures bmn
Structures bmnStructures bmn
Structures bmn
Sudha Lawrence
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
rohassanie
 
INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1
Mubarek Kurt
 
Fp201 unit4
Fp201 unit4Fp201 unit4
Fp201 unit4
rohassanie
 
Ch7 structures
Ch7 structuresCh7 structures
Ch7 structures
Hattori Sidek
 
Software Engineering-R.D.Sivakumar
Software Engineering-R.D.SivakumarSoftware Engineering-R.D.Sivakumar
Software Engineering-R.D.Sivakumar
Sivakumar R D .
 
Basic structure of C++ program
Basic structure of C++ programBasic structure of C++ program
Basic structure of C++ program
matiur rahman
 
Structure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarStructure of C++ - R.D.Sivakumar
Structure of C++ - R.D.Sivakumar
Sivakumar R D .
 
c++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programc++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ program
AAKASH KUMAR
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
Swarup Kumar Boro
 
Structures
StructuresStructures
Structures
archikabhatia
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
harman kaur
 

Andere mochten auch (20)

Savitch Ch 15
Savitch Ch 15Savitch Ch 15
Savitch Ch 15
 
Savitch Ch 07
Savitch Ch 07Savitch Ch 07
Savitch Ch 07
 
Savitch Ch 12
Savitch Ch 12Savitch Ch 12
Savitch Ch 12
 
Savitch Ch 08
Savitch Ch 08Savitch Ch 08
Savitch Ch 08
 
Savitch Ch 17
Savitch Ch 17Savitch Ch 17
Savitch Ch 17
 
Savitch ch 07
Savitch ch 07Savitch ch 07
Savitch ch 07
 
Cs1123 12 structures
Cs1123 12 structuresCs1123 12 structures
Cs1123 12 structures
 
Eee3420 lecture06 rev2011
Eee3420 lecture06 rev2011Eee3420 lecture06 rev2011
Eee3420 lecture06 rev2011
 
Structures bmn
Structures bmnStructures bmn
Structures bmn
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1
 
Fp201 unit4
Fp201 unit4Fp201 unit4
Fp201 unit4
 
Ch7 structures
Ch7 structuresCh7 structures
Ch7 structures
 
Software Engineering-R.D.Sivakumar
Software Engineering-R.D.SivakumarSoftware Engineering-R.D.Sivakumar
Software Engineering-R.D.Sivakumar
 
Basic structure of C++ program
Basic structure of C++ programBasic structure of C++ program
Basic structure of C++ program
 
Structure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarStructure of C++ - R.D.Sivakumar
Structure of C++ - R.D.Sivakumar
 
c++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programc++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ program
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
Structures
StructuresStructures
Structures
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
 

Ähnlich wie Savitch ch 01

Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
gaafergoda
 
Book ppt
Book pptBook ppt
Book ppt
FALLEE31188
 
C++ advanced PPT.pdf
C++ advanced PPT.pdfC++ advanced PPT.pdf
C++ advanced PPT.pdf
DinashMaliya3
 
Introduction To Computer and Java
Introduction To Computer and JavaIntroduction To Computer and Java
Introduction To Computer and Java
PRN USM
 
C 1
C 1C 1
Introduction
IntroductionIntroduction
Introduction
Kamran
 
CISY 105 Chapter 1
CISY 105 Chapter 1CISY 105 Chapter 1
CISY 105 Chapter 1
Jackie Marshall
 
Programming_Fundamentals_Chapter_1_INTRO.pdf
Programming_Fundamentals_Chapter_1_INTRO.pdfProgramming_Fundamentals_Chapter_1_INTRO.pdf
Programming_Fundamentals_Chapter_1_INTRO.pdf
BernardVelasco1
 
Chapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfChapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdf
KirubelWondwoson1
 
Lecture 1-3.ppt
Lecture 1-3.pptLecture 1-3.ppt
Lecture 1-3.ppt
HafeezullahJamro
 
6272 cnote
6272 cnote6272 cnote
6272 cnote
P Kiran Sree
 
C progrmming
C progrmmingC progrmming
C progrmming
Shivam Singhal
 
PPS Unit-1.pdf
PPS Unit-1.pdfPPS Unit-1.pdf
PPS Unit-1.pdf
NenavathSurendhar
 
Lecture01
Lecture01Lecture01
Lecture01
Xafran
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptx
Abdalla536859
 
Computer Programming - Lecture 1
Computer Programming - Lecture 1Computer Programming - Lecture 1
Computer Programming - Lecture 1
Dr. Md. Shohel Sayeed
 
Contents Pre-requisites Approximate .docx
   Contents Pre-requisites  Approximate .docx   Contents Pre-requisites  Approximate .docx
Contents Pre-requisites Approximate .docx
ShiraPrater50
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c language
Rai University
 
Week10 final
Week10 finalWeek10 final
Week10 final
Irfan Ali Memon
 
Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c language
Rai University
 

Ähnlich wie Savitch ch 01 (20)

Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
 
Book ppt
Book pptBook ppt
Book ppt
 
C++ advanced PPT.pdf
C++ advanced PPT.pdfC++ advanced PPT.pdf
C++ advanced PPT.pdf
 
Introduction To Computer and Java
Introduction To Computer and JavaIntroduction To Computer and Java
Introduction To Computer and Java
 
C 1
C 1C 1
C 1
 
Introduction
IntroductionIntroduction
Introduction
 
CISY 105 Chapter 1
CISY 105 Chapter 1CISY 105 Chapter 1
CISY 105 Chapter 1
 
Programming_Fundamentals_Chapter_1_INTRO.pdf
Programming_Fundamentals_Chapter_1_INTRO.pdfProgramming_Fundamentals_Chapter_1_INTRO.pdf
Programming_Fundamentals_Chapter_1_INTRO.pdf
 
Chapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfChapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdf
 
Lecture 1-3.ppt
Lecture 1-3.pptLecture 1-3.ppt
Lecture 1-3.ppt
 
6272 cnote
6272 cnote6272 cnote
6272 cnote
 
C progrmming
C progrmmingC progrmming
C progrmming
 
PPS Unit-1.pdf
PPS Unit-1.pdfPPS Unit-1.pdf
PPS Unit-1.pdf
 
Lecture01
Lecture01Lecture01
Lecture01
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptx
 
Computer Programming - Lecture 1
Computer Programming - Lecture 1Computer Programming - Lecture 1
Computer Programming - Lecture 1
 
Contents Pre-requisites Approximate .docx
   Contents Pre-requisites  Approximate .docx   Contents Pre-requisites  Approximate .docx
Contents Pre-requisites Approximate .docx
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c language
 
Week10 final
Week10 finalWeek10 final
Week10 final
 
Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c language
 

Mehr von Terry Yoast

9781305078444 ppt ch12
9781305078444 ppt ch129781305078444 ppt ch12
9781305078444 ppt ch12
Terry Yoast
 
9781305078444 ppt ch11
9781305078444 ppt ch119781305078444 ppt ch11
9781305078444 ppt ch11
Terry Yoast
 
9781305078444 ppt ch10
9781305078444 ppt ch109781305078444 ppt ch10
9781305078444 ppt ch10
Terry Yoast
 
9781305078444 ppt ch09
9781305078444 ppt ch099781305078444 ppt ch09
9781305078444 ppt ch09
Terry Yoast
 
9781305078444 ppt ch08
9781305078444 ppt ch089781305078444 ppt ch08
9781305078444 ppt ch08
Terry Yoast
 
9781305078444 ppt ch07
9781305078444 ppt ch079781305078444 ppt ch07
9781305078444 ppt ch07
Terry Yoast
 
9781305078444 ppt ch06
9781305078444 ppt ch069781305078444 ppt ch06
9781305078444 ppt ch06
Terry Yoast
 
9781305078444 ppt ch05
9781305078444 ppt ch059781305078444 ppt ch05
9781305078444 ppt ch05
Terry Yoast
 
9781305078444 ppt ch04
9781305078444 ppt ch049781305078444 ppt ch04
9781305078444 ppt ch04
Terry Yoast
 
9781305078444 ppt ch03
9781305078444 ppt ch039781305078444 ppt ch03
9781305078444 ppt ch03
Terry Yoast
 
9781305078444 ppt ch02
9781305078444 ppt ch029781305078444 ppt ch02
9781305078444 ppt ch02
Terry Yoast
 
9781305078444 ppt ch01
9781305078444 ppt ch019781305078444 ppt ch01
9781305078444 ppt ch01
Terry Yoast
 
9781337102087 ppt ch13
9781337102087 ppt ch139781337102087 ppt ch13
9781337102087 ppt ch13
Terry Yoast
 
9781337102087 ppt ch18
9781337102087 ppt ch189781337102087 ppt ch18
9781337102087 ppt ch18
Terry Yoast
 
9781337102087 ppt ch17
9781337102087 ppt ch179781337102087 ppt ch17
9781337102087 ppt ch17
Terry Yoast
 
9781337102087 ppt ch16
9781337102087 ppt ch169781337102087 ppt ch16
9781337102087 ppt ch16
Terry Yoast
 
9781337102087 ppt ch15
9781337102087 ppt ch159781337102087 ppt ch15
9781337102087 ppt ch15
Terry Yoast
 
9781337102087 ppt ch14
9781337102087 ppt ch149781337102087 ppt ch14
9781337102087 ppt ch14
Terry Yoast
 
9781337102087 ppt ch12
9781337102087 ppt ch129781337102087 ppt ch12
9781337102087 ppt ch12
Terry Yoast
 
9781337102087 ppt ch11
9781337102087 ppt ch119781337102087 ppt ch11
9781337102087 ppt ch11
Terry Yoast
 

Mehr von Terry Yoast (20)

9781305078444 ppt ch12
9781305078444 ppt ch129781305078444 ppt ch12
9781305078444 ppt ch12
 
9781305078444 ppt ch11
9781305078444 ppt ch119781305078444 ppt ch11
9781305078444 ppt ch11
 
9781305078444 ppt ch10
9781305078444 ppt ch109781305078444 ppt ch10
9781305078444 ppt ch10
 
9781305078444 ppt ch09
9781305078444 ppt ch099781305078444 ppt ch09
9781305078444 ppt ch09
 
9781305078444 ppt ch08
9781305078444 ppt ch089781305078444 ppt ch08
9781305078444 ppt ch08
 
9781305078444 ppt ch07
9781305078444 ppt ch079781305078444 ppt ch07
9781305078444 ppt ch07
 
9781305078444 ppt ch06
9781305078444 ppt ch069781305078444 ppt ch06
9781305078444 ppt ch06
 
9781305078444 ppt ch05
9781305078444 ppt ch059781305078444 ppt ch05
9781305078444 ppt ch05
 
9781305078444 ppt ch04
9781305078444 ppt ch049781305078444 ppt ch04
9781305078444 ppt ch04
 
9781305078444 ppt ch03
9781305078444 ppt ch039781305078444 ppt ch03
9781305078444 ppt ch03
 
9781305078444 ppt ch02
9781305078444 ppt ch029781305078444 ppt ch02
9781305078444 ppt ch02
 
9781305078444 ppt ch01
9781305078444 ppt ch019781305078444 ppt ch01
9781305078444 ppt ch01
 
9781337102087 ppt ch13
9781337102087 ppt ch139781337102087 ppt ch13
9781337102087 ppt ch13
 
9781337102087 ppt ch18
9781337102087 ppt ch189781337102087 ppt ch18
9781337102087 ppt ch18
 
9781337102087 ppt ch17
9781337102087 ppt ch179781337102087 ppt ch17
9781337102087 ppt ch17
 
9781337102087 ppt ch16
9781337102087 ppt ch169781337102087 ppt ch16
9781337102087 ppt ch16
 
9781337102087 ppt ch15
9781337102087 ppt ch159781337102087 ppt ch15
9781337102087 ppt ch15
 
9781337102087 ppt ch14
9781337102087 ppt ch149781337102087 ppt ch14
9781337102087 ppt ch14
 
9781337102087 ppt ch12
9781337102087 ppt ch129781337102087 ppt ch12
9781337102087 ppt ch12
 
9781337102087 ppt ch11
9781337102087 ppt ch119781337102087 ppt ch11
9781337102087 ppt ch11
 

Kürzlich hochgeladen

High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
bhumivarma35300
 
CiscoIconsLibrary cours de réseau VLAN.ppt
CiscoIconsLibrary cours de réseau VLAN.pptCiscoIconsLibrary cours de réseau VLAN.ppt
CiscoIconsLibrary cours de réseau VLAN.ppt
moinahousna
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
Lidia A.
 
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python CodebaseEuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
Jimmy Lai
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
SynapseIndia
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Mydbops
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
Google Developer Group - Harare
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
huseindihon
 
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Muhammad Ali
 
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
Edge AI and Vision Alliance
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
rajancomputerfbd
 
The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
Shiv Technolabs
 
WhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring AppsWhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring Apps
HackersList
 
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
alexjohnson7307
 
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes..."Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
Anant Gupta
 
July Patch Tuesday
July Patch TuesdayJuly Patch Tuesday
July Patch Tuesday
Ivanti
 
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSECHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
kumarjarun2010
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
Safe Software
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Networks
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 

Kürzlich hochgeladen (20)

High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
 
CiscoIconsLibrary cours de réseau VLAN.ppt
CiscoIconsLibrary cours de réseau VLAN.pptCiscoIconsLibrary cours de réseau VLAN.ppt
CiscoIconsLibrary cours de réseau VLAN.ppt
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
 
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python CodebaseEuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
 
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
 
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
 
The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
 
WhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring AppsWhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring Apps
 
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
 
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes..."Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
 
July Patch Tuesday
July Patch TuesdayJuly Patch Tuesday
July Patch Tuesday
 
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSECHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 

Savitch ch 01

  • 1.  
  • 2. Chapter 1 Introduction to Computers and C++ Programming
  • 3. Overview 1.1 Computer Systems 1.2 Programming and Problem Solving 1.3 Introduction to C++ 1.4 Testing and Debugging Slide 1-
  • 5. Computer Systems A computer program is… A set of instructions for a computer to follow Computer software is … The collection of programs used by a computer Includes: Editors Translators System Managers Slide 1-
  • 6. Hardware Three main classes of computers PCs (Personal Computer) Relatively small used by one person at a time Workstation Larger and more powerful than a PC Mainframe Still larger Requires support staff Shared by multiple users Slide 1-
  • 7. Networks A number of computers connected to share resources Share printers and other devices Share information Slide 1-
  • 8. Computer Organization Five main components Input devices Allows communication to the computer Output devices Allows communication to the user Processor (CPU) Main memory Memory locations containing the running program Secondary memory Permanent record of data often on a disk Slide 1- Display 1.1
  • 9. Computer Memory Main Memory Long list of memory locations Each contains zeros and ones Can change during program execution Binary Digit or Bit A digit that can only be zero or one Byte Each memory location has eight bits Address Number that identifies a memory location Slide 1-
  • 10. Larger Data Items Some data is too large for a single byte Most integers and real numbers are too large Address refers to the first byte Next few consecutive bytes can store the additional bits for larger data Slide 1- Display 1.2
  • 11. Data or Code? ‘ A’ may look like 01000001 65 may look like 01000001 An instruction may look like 01000001 How does the computer know the meaning of 01000001? Interpretation depends on the current instruction Programmers rarely need to be concerned with this problem. Reason as if memory locations contain letters and numbers rather than zeroes and ones Slide 1-
  • 12. Secondary Memory Main memory stores instructions and data while a program is running. Secondary memory Stores instructions and data between sessions A file stores data or instructions in secondary memory Slide 1-
  • 13. Secondary Memory Media A computer might have any of these types of secondary memory Hard disk Fast Fixed in the computer and not normally removed Floppy disk Slow Easily shared with other computers Compact disk Slower than hard disks Easily shared with other computers Can be read only or re-writable Slide 1-
  • 14. Memory Access Random Access Usually called RAM Computer can directly access any memory location Sequential Access Data is generally found by searching through other items first More common in secondary memory Slide 1-
  • 15. The Processor Typically called the CPU Central Processing Unit Follows program instructions Typical capabilities of CPU include: add subtract multiply divide move data from location to location Slide 1-
  • 16. Computer Software The operating system Allows us to communicate with the computer Is a program Allocates the computer’s resources Responds to user requests to run other programs Common operating systems include… UNIX Linux DOS Windows Macintosh VMS Slide 1-
  • 17. Computer Input Computer input consists of A program Some data Slide 1- Display 1.3
  • 18. High-level Languages Common programming languages include … C C++ Java Pascal Visual Basic FORTRAN Perl COBOL Lisp Scheme Ada C# Python These high – level languages Resemble human languages Are designed to be easy to read and write Use more complicated instructions than the CPU can follow Must be translated to zeros and ones for the CPU to execute a program Slide 1-
  • 19. Low-level Languages An assembly language command such as ADD X Y Z might mean add the values found at x and y in memory, and store the result in location z. Assembly language must be translated to machine language (zeros and ones) 0110 1001 1010 1011 The CPU can follow machine language Slide 1-
  • 20. Compilers Translate high-level language to machine language Source code The original program in a high level language Object code The translated version in machine language Slide 1- Display 1.4
  • 21. Linkers Some programs we use are already compiled Their object code is available for us to use For example: Input and output routines A Linker combines The object code for the programs we write and The object code for the pre-compiled routines into The machine language program the CPU can run Slide 1- Display 1.5
  • 22. History Note First programmable computer Designed by Charles Babbage Began work in 1822 Not completed in Babbage’s life time First programmer Ada Augusta, Countess of Lovelace Colleague of Babbage Slide 1-
  • 23. Section 1.1 Conclusion Can you… List the five main components of a computer? List the data for a program that adds two numbers? Describe the work of a compiler? Define source code? Define object code? Describe the purpose of the operating system? Slide 1-
  • 24. 1.2 Programming and Problem-Solving
  • 25. Algorithms Algorithm A sequence of precise instructions that leads to a solution Program An algorithm expressed in a language the computer can understand Slide 1- Display 1.6
  • 26. Program Design Programming is a creative process No complete set of rules for creating a program Program Design Process Problem Solving Phase Result is an algorithm that solves the problem Implementation Phase Result is the algorithm translated into a programming language Slide 1-
  • 27. Problem Solving Phase Be certain the task is completely specified What is the input? What information is in the output? How is the output organized? Develop the algorithm before implementation Experience shows this saves time in getting your program to run. Test the algorithm for correctness Slide 1-
  • 28. Implementation Phase Translate the algorithm into a programming language Easier as you gain experience with the language Compile the source code Locates errors in using the programming language Run the program on sample data Verify correctness of results Results may require modification of the algorithm and program Slide 1- Display 1.7
  • 29. Object Oriented Programming Abbreviated OOP Used for many modern programs Program is viewed as interacting objects Each object contains algorithms to describe its behavior Program design phase involves designing objects and their algorithms Slide 1-
  • 30. OOP Characteristics Encapsulation Information hiding Objects contain their own data and algorithms Inheritance Writing reusable code Objects can inherit characteristics from other objects Polymorphism A single name can have multiple meanings depending on its context Slide 1-
  • 31. Software Life Cycle Analysis and specification of the task (problem definition) Design of the software (object and algorithm design) Implementation (coding) Maintenance and evolution of the system Obsolescence Slide 1-
  • 32. Section 1.2 Conclusion Can you… Describe the first step to take when creating a program? List the two main phases of the program design process? Explain the importance of the problem-solving phase? List the steps in the software life cycle? Slide 1-
  • 34. Introduction to C++ Where did C++ come from? Derived from the C language C was derived from the B language B was derived from the BCPL language Why the ‘++’? ++ is an operator in C++ and results in a cute pun Slide 1-
  • 35. C++ History C developed by Dennis Ritchie at AT&T Bell Labs in the 1970s. Used to maintain UNIX systems Many commercial applications written in c C++ developed by Bjarne Stroustrup at AT&T Bell Labs in the 1980s. Overcame several shortcomings of C Incorporated object oriented programming C remains a subset of C++ Slide 1-
  • 36. A Sample C++ Program A simple C++ program begins this way #include <iostream> using namespace std; int main() { And ends this way return 0; } Slide 1- Display 1.8
  • 37. Explanation of code (1/5) Variable declaration line int number_of_pods, peas_per_pod, total_peas; Identifies names of three variables to name numbers int means that the variables represent integers Slide 1-
  • 38. Explanation of code (2/5) Program statement cout << “Press return after entering a number.”; cout (see-out) used for output to the monitor “ <<“ inserts “Press…a number.” in the data bound for the monitor Think of cout as a name for the monitor “ <<“ points to where the data is to end up ‘ ’ causes a new line to be started on the monitor Slide 1-
  • 39. Explanation of code (3/5) Program statement cin >> number_of_pods; cin (see-in) used for input from the keyboard “ >>” extracts data from the keyboard Think of cin as a name for the keyboard “ >>” points from the keyboard to a variable where the data is stored Slide 1-
  • 40. Explanation of code (4/5) Program statement total_peas = number_of_pods * peas_per_pod; Performs a computation ‘ *’ is used for multiplication ‘ =‘ causes total_peas to get a new value based on the calculation shown on the right of the equal sign Slide 1-
  • 41. Explanation of code (5/5) Program statement cout << number_of_pods; Sends the value of variable number_of_pods to the monitor Slide 1-
  • 42. Program Layout (1/3) Compiler accepts almost any pattern of line breaks and indentation Programmers format programs so they are easy to read Place opening brace ‘{‘ and closing brace ‘}’ on a line by themselves Indent statements Use only one statement per line Slide 1-
  • 43. Program Layout (2/3) Variables are declared before they are used Typically variables are declared at the beginning of the program Statements (not always lines) end with a semi-colon Include Directives #include <iostream> Tells compiler where to find information about items used in the program iostream is a library containing definitions of cin and cout Slide 1-
  • 44. Program Layout (3/3) using namespace std; Tells the compiler to use names in iostream in a “standard” way To begin the main function of the program int main() { To end the main function return 0; } Main function ends with a return statement Slide 1-
  • 45. Running a C++ Program C++ source code is written with a text editor The compiler on your system converts source code to object code. The linker combines all the object code into an executable program. Slide 1-
  • 46. Run a Program Obtain code in Display 1.10 Compile the code Fix any errors the compiler indicates and re-compile the code Run the program Now you know how to run a program on your system Slide 1- Display 1.10
  • 47. Section 1.3 Conclusion Can you… Describe the output of this line? cout << “C++ is easy to understand.”; Explain what this line does? cin >> peas_per_pod; Explain this? #include <iostream> Slide 1-
  • 48. 1.4 Testing and Debugging
  • 49. Testing and Debugging Bug A mistake in a program Debugging Eliminating mistakes in programs Term used when a moth caused a failed relay on the Harvard Mark 1 computer. Grace Hopper and other programmers taped the moth in logbook stating: “First actual case of a bug being found.” Slide 1-
  • 50. Program Errors Syntax errors Violation of the grammar rules of the language Discovered by the compiler Error messages may not always show correct location of errors Run-time errors Error conditions detected by the computer at run-time Logic errors Errors in the program’s algorithm Most difficult to diagnose Computer does not recognize an error Slide 1-
  • 51. Section 1-4 Conclusion Can you… Describe the three kinds of program errors? Tell what kind of errors the compiler catches? What kind of error is produced if you forget a punctuation symbol such as a semi-colon? Tell what type of error is produced when a program runs but produces incorrect results? Slide 1-
  • 52. Chapter 1 -- End Slide 1-
  • 53. Display 1.1 Slide 1- Back Next
  • 54. Display 1.2 Slide 1- Back Next
  • 55. Display 1.3 Slide 1- Back Next
  • 56. Display 1.4 Slide 1- Back Next
  • 57. Display 1.5 Slide 1- Back Next
  • 58. Display 1.6 Slide 1- Back Next
  • 59. Display 1.7 Slide 1- Back Next
  • 60. Display 1.8 Slide 1- Next Back
  • 61. Display 1.9 Slide 1- Back Next
  • 62. Display 1.10 Slide 1- Next Back