Computer Programming in C++ 黃鐘揚 教授 Prof. Chung-Yang (Ric) Huang Department of Electrical Engineering National Taiwan University 2007/06/26.

Slides:



Advertisements
Similar presentations
Written by: Dr. JJ Shepherd
Advertisements

 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 1.
Lecture 2 Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
CSE Spring 2015 INTERMEDIATE PROGRAMMING
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
COSC 120 Computer Programming
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 4 – C Program Control Outline 4.1Introduction.
 2006 Pearson Education, Inc. All rights reserved Operator Overloading.
 2006 Pearson Education, Inc. All rights reserved Introduction.
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
Wednesday, 12/11/02, Slide #1 CS 106 Intro to Comp. Sci. 1 Wednesday, 12/11/02  QUESTIONS??  Today: CLOSING CEREMONIES!  HW #5 – Back Monday (12/16)
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 8 - Interest Calculator Application: Introducing.
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection Statement 4.6 if else Selection Statement 4.7 while.
Topic R3 – Review for the Final Exam. CISC 105 – Review for the Final Exam Exam Date & Time and Exam Format The final exam is 120-minutes, closed- book,
 2006 Pearson Education, Inc. All rights reserved Introduction.
 2007 Pearson Education, Inc. All rights reserved C Program Control.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 4 - Program Control Outline 4.1Introduction 4.2The Essentials of Repetition 4.3Counter-Controlled.
COMP1170 Midterm Preparation (March 17 th 2009) Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved The switch Multiple-Selection Statement switch.
C How to Program, 6/e Summary © by Pearson Education, Inc. All Rights Reserved.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
C++ Programming Language Day 1. What this course covers Day 1 – Structure of C++ program – Basic data types – Standard input, output streams – Selection.
Java Course Outline Kumar Harshit, USW. Course Description Teaches students to program using the Java programming language with the help of the Netbeans.
COMPUTER SCIENCE I C++ INTRODUCTION
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
The University of Texas – Pan American
High-Level Programming Languages: C++
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 8 - Interest Calculator Application: Introducing.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 4 - Program Control Outline 4.1Introduction 4.2The Essentials of Repetition 4.3Counter-Controlled.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Wage Calculator Application: Introducing.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 3 Selections.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Java ProgrammingtMyn1 Java Programming Timo Mynttinen Mikkeli University of Applied Sciences.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Week 1 Algorithmization and Programming Languages.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Fundamental Programming: Fundamental Programming Introduction to C++
CS Class 05 Topics  Selection: switch statement Announcements  Read pages 74-83, ,
CSCI/CMPE 4341 Topic: Programming in Python Review: Exam I Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
C++ Lecture 1 Friday, 4 July History of C++ l Built on top of C l C was developed in early 70s from B and BCPL l Object oriented programming paradigm.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
Introduction to C Programming Lecture 6. Functions – Call by value – Call by reference Arrays Today's Lecture Includes.
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessor Midterm Review Lecture 7 Feb 17, 2004.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Written by: Dr. JJ Shepherd
Lecturer: Nguyen Thi Hien Software Engineering Department Home page: hienngong.wordpress.com Chapter 2: Language C++
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
CISC105 – General Computer Science Class 4 – 06/14/2006.
Dr. Sajib Datta Jan 15,  Instructor: Sajib Datta ◦ Office Location: ERB 336 ◦ Address: ◦ Web Site:
 2003 Prentice Hall, Inc. All rights reserved. 1 Basic C++ Programming.
Object-Oriented Programming (OOP) and C++
C++ Lesson 1.
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
3-4-5 Introduction.
3-4-5 Introduction.
Presentation transcript:

Computer Programming in C++ 黃鐘揚 教授 Prof. Chung-Yang (Ric) Huang Department of Electrical Engineering National Taiwan University 2007/06/26

06/27/07 Chung-Yang (Ric) Huang Course Info 8 Meetings, 3 hours each Text Book C++ How to Program, 5e, Deitel & Deitel Grading 1-2 homeworks (TBD) 1 final exam or project Contact EE-II TA: 葉護熺

06/27/07 Chung-Yang (Ric) Huang Course Outline 1. Introduction to Computers, the Internet and WWW 2. Intro to C++ Programming 3. Intro to Classes and Objects 4. Control Statements: Part I 5. Control Statements: Part II 6. Functions and an Intro to Recursion 7. Array and Vectors 8. Pointers and Pointer-Based Strings

06/27/07 Chung-Yang (Ric) Huang Course Outline 9. Classes: A Deeper Look, Part I 10. Classes: A Deeper Look, Part II 11. Operator Overloading: String and Array Objects 12. Object-Oriented Programming: Inheritance 13. Object-Oriented Programming: Polymorphism 14. Templates 15. Stream I/O 16. Exception Handling

06/27/07 Chung-Yang (Ric) Huang Course Outline 17. File Processing 18. Class string and String Stream Processing 19. Web Programming 20. Searching and Sorting 21. Data Structures 22. Standard Template Library (STL) 23. Other Topics

06/27/07 Chung-Yang (Ric) Huang Components in C++ 1. Keyword 2. Function 3. Variable (object) 4. Data type 5. Name space 6. Comments

06/27/07 Chung-Yang (Ric) Huang Components in C++ 1. Keyword Procedure control (e.g. if, else, for, while, do, break, continue, return, using, try, throw, catch … ) Symbols (e.g. { }, ( ), &, |, ^, &&, ||, ~, !, *, ->, >, >, <<, “”, ‘’, \,, … ) Type declaration (e.g. class, struct, union, public, protected, private, virtual … ) Attribute (e.g. const, static … ) Constant (e.g. 1, 23, 456, 0xff08, true, false, string “ xxxx ”, ….) Predefined types (e.g. int, char, unsigned, short int, long int, float, double … ) Preprocessor deritives (e.g. #include, #ifdef, … )

06/27/07 Chung-Yang (Ric) Huang Components in C++ 2. Function main From standard library (e.g. exit, printf … ) User defined 3. Variable (object) From standard library (e.g. cout, cin … ) User defined

06/27/07 Chung-Yang (Ric) Huang Components in C++ 4. Data type Predefined types (also treated as keywaords) From standard library (e.g. iostream, fstream, vector … ) User defined 5. Name space std User defined 6. Comments Single-line (started with // ) Multiple-line (enclosed by /* */)

06/27/07 Chung-Yang (Ric) Huang Practice Prog-2.1 Write a program … just use cin and cout > Enter the first score : 80 > Enter the second score: 90 > Enter the thrid score : > The average is : 85

06/27/07 Chung-Yang (Ric) Huang Practice Prog-2.2 Follow Prog-2.1 > Enter the first name : Sam > Enter the first score : 80 > Enter the second name : Claire > Enter the second score: > Sam’s score is 80 > Claire’s score is 90

06/27/07 Chung-Yang (Ric) Huang Practice Prog-2.3 Continued from Prog-2.2. However, check if the entered score is between 0 and 100. If not issue an error message as follows: > Enter the first score : -30 Error: “ -30 ” is not a legal score !!

 2006 Pearson Education, Inc. All rights reserved Introduction 1.2 What Is a Computer? 1.3 Computer Organization 1.4 Early Operating Systems 1.5 Personal, Distributed and Client/Server Computing 1.6 The Internet and the World Wide Web 1.7 Machine Languages, Assembly Languages and High-Level Languages 1.8 History of C and C C++ Standard Library 1.10 History of Java 1.11 FORTRAN, COBOL, Pascal and Ada 1.12 Basic, Visual Basic, Visual C++, C# and.NET 1.13 Key Software Trend: Object Technology 1.14 Typical C++ Development Environment 1.15 Notes About C++ and C++ How to Program, 5/e 1.16 Test-Driving a C++ Application 1.17 Software Engineering Case Study: Introduction to Object Technology and the UML (Required) 1.18 Wrap-Up 1.19 Web Resources

 2006 Pearson Education, Inc. All rights reserved Introduction 2.2 First Program in C++: Printing a Line of Text 2.3 Modifying Our First C++ Program 2.4 Another C++ Program: Adding Integers 2.5 Memory Concepts 2.6 Arithmetic 2.7 Decision Making: Equality and Relational Operators 2.8 (Optional) Software Engineering Case Study: Examining the ATM Requirements Document 2.9 Wrap-Up

 2006 Pearson Education, Inc. All rights reserved Introduction 3.2 Classes, Objects, Member Functions and Data Members 3.3 Overview of the Chapter Examples 3.4 Defining a Class with a Member Function 3.5 Defining a Member Function with a Parameter 3.6 Data Members, set Functions and get Functions 3.7 Initializing Objects with Constructors 3.8 Placing a Class in a Separate File for Reusability 3.9 Separating Interface from Implementation 3.10 Validating Data with set Functions 3.11 (Optional) Software Engineering Case Study: Identifying the Classes in the ATM Requirements Document 3.12 Wrap-Up

 2006 Pearson Education, Inc. All rights reserved Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Selection Statement 4.6 if...else Double-Selection Statement 4.7 while Repetition Statement 4.8 Formulating Algorithms: Counter-Controlled Repetition 4.9 Formulating Algorithms: Sentinel-Controlled Repetition 4.10 Formulating Algorithms: Nested Control Statements 4.11 Assignment Operators 4.12 Increment and Decrement Operators 4.13 (Optional) Software Engineering Case Study: Identifying Class Attributes in the ATM System 4.14 Wrap-Up

 2006 Pearson Education, Inc. All rights reserved Introduction 5.2 Essentials of Counter-Controlled Repetition 5.3 for Repetition Statement 5.4 Examples Using the for Statement 5.5 do … while Repetition Statement 5.6 switch Multiple-Selection Statement 5.7 break and continue Statements 5.8 Logical Operators 5.9 Confusing Equality ( == ) and Assignment ( = ) Operators 5.10 Structured Programming Summary 5.11 (Optional) Software Engineering Case Study: Identifying Objects’ States and Activities in the ATM System 5.12 Wrap-Up

06/27/07 Chung-Yang (Ric) Huang Practice Prog-3.1 Similar to Prog-2.1, but create a class called “ Student ” and store the scores and average as its data members. Use member functions to set and get. > Enter the first score : 80 > Enter the second score: 90 > Enter the third score : > The average is : 85

06/27/07 Chung-Yang (Ric) Huang Practice Prog-4.1 Guess Number: > Enter the range [1 ~ ?]: 100 > Please guess a number: 50 > => Too small!! > Please guess a number: 75 > => Too large!! > Please guess a number: 63 > => You are right!! > Play again? (Y/N) N > *** Good-Bye!! Have a nice day!! ***

06/27/07 Chung-Yang (Ric) Huang Tips & Issues about Prog. 4-1 How to generate random numbers? Calling function “ rand() ” (for Windows) How to generate random numbers between 1 and 100 ? y = rand() % ; Is the random number the same every time you play? How to fix it? (Homework) Try to google this problem. Do you check whether the input number is within the legal range? What if the player makes a stupid guess? For “ Play again? (Y/N) ”, can we accept “ default value ” (i.e. no enter)? Do you create any “ class ” for this program? Why yes and why not?

06/27/07 Chung-Yang (Ric) Huang Admin Info 07/18/07 A class website will be created ramming/S07-tl ramming/S07-tl Practice programs This file Announcements Final homework/project will be announced online next week You are encouraged to think about the problem as early as possible Tentative due date: 08/13 (Monday) Submission method: TBA