Chapter 1 ABSOLUTE C++ C++Basics WALTER SAVITCH SECOND EDITION PEARSON Copyright2006 Pearson Addison-Wesley.All rights reserved
Chapter 1 C++ Basics
Learning Objectives ◆Introduction to C++ Origins,Object-Oriented Programming,Terms Variables,Expressions,and Assignment Statements Console Input/Output ◆Program Style Libraries and Namespaces Copyright2006 Pears on Addison-Wesley.All rights reserved. 1-2
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-2 Learning Objectives Introduction to C++ Origins, Object-Oriented Programming, Terms Variables, Expressions, and Assignment Statements Console Input/Output Program Style Libraries and Namespaces
Introduction to C++ ◆C++Origins ◆Low-level languages ◆Machine,assembly High-level languages +C,C++,ADA,COBOL,FORTRAN Object-Oriented-Programming in C++ ◆Ct+Terminology Programs and functions Basic Input/Output(1/O)with cin and cout Copyright2006 Pears on Addison-Wesley.All rights reserved. 1-3
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-3 Introduction to C++ C++ Origins Low-level languages Machine, assembly High-level languages C, C++, ADA, COBOL, FORTRAN Object-Oriented-Programming in C++ C++ Terminology Programs and functions Basic Input/Output (I/O) with cin and cout
Display 1.1 A Sample C++Program(1 of 2) Display 1.A Sample C++Program 1 #include <iostream> 2 using namespace std; 3 int main() 4 int numberOfLanguages; 6 cout <"Hello reader.\n" 7 <"Welcome to C++.\n"; cout <"How many programming languages have you used?" 9 cin >numberOfLanguages; 10 if (numberofLanguages 1) 11 cout <"Read the preface.You may prefer\n" 2 <<"a more elementary book by the same author.\n"; 13 else 14 cout <"Enjoy the book.\n"; 15 return 0; 163 Copyright2006 Pears on Addison-Wesley.All rights reserved. 1-4
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-4 Display 1.1 A Sample C++ Program (1 of 2)
Display 1.1 A Sample C++Program(2 of 2) SAMPLE DIALOGUE I Hello reader. Welcome to C++. How many programming languages have you used?0-User types in 0 on the keyboard. Read the preface.You may prefer a more elementary book by the same author. SAMPLE DIALOGUE 2 Hello reader. Welcome to C++. How many programming languages have you used?1-User types in 1 on the keyboard. Enjoy the book Copyright 2006 Pearson Addison-Wesley.All rights reserved. 1-5
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-5 Display 1.1 A Sample C++ Program (2 of 2)