Chapter 02 (Part I) Introduction to C++ Programming.

Slides:



Advertisements
Similar presentations
EC-111 Algorithms & Computing Lecture #1 Instructor: Jahan Zeb Department of Computer Engineering (DCE) College of E&ME NUST.
Advertisements

 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 1 – Introduction to Computers and C++ Programming Outline 1.1 Introduction 1.2 What is a Computer?
Introduction Kingdom of Saudi Arabia Shaqra University
五小專案 黃詩晴 章乃云. 目錄 計算機 智慧盤 拼圖 記憶大挑戰 數學題庫 心得 參考文獻.
最新計算機概論 第 5 章 系統程式. 5-1 系統程式的類型 作業系統 (OS) : 介於電腦硬體與 應用軟體之間的 程式,除了提供 執行應用軟體的 環境,還負責分 配系統資源。
Three types of computer languages
CH.8 偵錯 Visual Basic CH.8 偵錯 Visual Basic  資三甲   章乃云 三種類型的錯誤 三種類型的錯誤.
下載 Dev C++ Compiler. 網址 ding.php?groupnamehttp://sourceforge.net/project/downloa ding.php?groupname=dev-cpp & filename=devcpp _setup.exe.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 1 – Introduction to Computers and C++ Programming.
 2003 Prentice Hall, Inc. All rights reserved Computer Organization Six logical units of computer 1.Input unit “Receiving” section Obtains information.
 2003 Prentice Hall, Inc. All rights reserved. 1 Machine Languages, Assembly Languages, and High-level Languages Three types of computer languages 1.Machine.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 1 – Introduction to Computers and C++ Programming Outline 1.1Introduction 1.2What Is a Computer?
August 29, 2005ICP: Chapter 0: Introduction to Computers and Computing 1 Introduction or Computer Programming Chapter 0: Introduction to Computers and.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
 2000 Prentice Hall, Inc. All rights reserved. 1 Introduction to Computers and C Programming Outline Introduction What Is a Computer? Computer Organization.
C programming language Computer Programming Language 計算機程式設計 Chapter 1 Overview 台大電機系 吳安宇教授 Sept
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Introduction to Computers and Python. What is a Computer? Computer- a device capable of performing computations and making logical decisions at speeds.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
COMPUTER SCIENCE I C++ INTRODUCTION
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
1 Chapter 1 - Introduction to Computers, the Internet, and the World Wide Web Outline 1.1Introduction 1.2What Is a Computer? 1.3Computer Organization 1.4Evolution.
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
 2008 Pearson Education, Inc. All rights reserved. 1 The chief merit of language is clearness. — Galen Our life is frittered away by detail…. Simplify,
Lecture 1: Introduction to Computers. OBJECTIVES In this lecture you will learn:  Basic computer concepts.  The different types of programming languages.
Programming Design Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
 2008 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
Lecture 1 Introduction to computers & VB.Net. What is a Computer? Examples? A device capable of  Performing computation  Making logical decisions 
Spring 2005, Gülcihan Özdemir Dağ BIL104E: Introduction to Scientific and Engineering Computing, Spring Outline 1.1Introduction 1.2What Is a Computer?
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Computer Organization Six logical units in every.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Introduction to Computers Outline 1.1Introduction.
 2006 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
 2008 Pearson Education, Inc. All rights reserved. 1 CISC 1600 – Computer Science I Fall 2010 Introduction to C++ Programming Chapters 1 and 2 (Deitel.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 1 Introduction to Computers, the Internet and.
Outline 1 MECH 215 Programming for Mech. and Ind. Eng. I Prof. Chadi Assi CB , Ext. 5799
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
INTRODUCTION Kingdom of Saudi Arabia Princess Nora bint Abdul Rahman University College of Computer Since and Information System CS240.
Programming Fundamentals1 Chapter 1 INTRODUCTION TO COMPUTER AND PROGRAMMING.
Chapter 1 Introduction to Computers and C++ Programming Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng.
1 MIS 131 Introduction to Algorithms and Programming 2015/2016 Fall - Chapter 1 -
1 Programming Fundamentals How to Program in C++ How to Program in C++
COMPUTER PROGRAMMING. Computer programming the objective of the module to gain the necessary skills to develop a computer program using one of the high.
Spring 09- ICE0124 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 1.
1 Object-Oriented Programming -- Using C++ Andres, Wen-Yuan Liao Department of Computer Science and Engineering De Lin Institute of Technology
 2008 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 1 – Introduction to Computers, the Internet and the World Wide Web Outline 1.1Introduction 1.2What.
CS2301:Computer Programming 2
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
1 Introduction to Computers, the Internet and World Wide Web.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
CHAPTER 1.1 INTRODUCTION TO COMPUTERS AND C++ Dr. Shady Yehia Elmashad.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming Dr. Halla Abdel Hameed.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
 2003 Prentice Hall, Inc. All rights reserved Introduction Software –Instructions to command computer to perform actions and make decisions Hardware.
Chapter 1: Introduction to computers and C++ Programming
Introduction to Computers
1.2 What is a Computer? Computer Computer programs Hardware Software
Introduction to Programming
Chapter 1 – Introduction to Computers and C++ Programming
Introduction to Computer Programming
Presentation transcript:

Chapter 02 (Part I) Introduction to C++ Programming

Goal Introduction C++ Development Environment First Program in C++: –Printing a line of text

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 –Written by people called computer programmers Hardware –Various devices comprising computer Keyboard, screen, mouse, disks, memory, CD-ROM, processing units, etc.

Computer Organization Six logical units of computer –Input unit “Receiving” section Obtains information from input devices –Keyboard, mouse, microphone, scanner, networks, etc. –Output unit “Shipping” section Places information processed by computer on output devices –Screen, printer, networks, etc.

Computer Organization Six logical units of computer (Cont.) –Memory unit Rapid access, relatively low capacity. Retains information from input unit. –Immediately available for processing Retains processed information. –Until placed on output devices Often called memory or primary memory. –Arithmetic and logic unit (ALU) Performs arithmetic calculations and logic decisions

Computer Organization Six logical units of computer (Cont.) –Central processing unit (CPU) “Administrative” section Coordinates and supervises other sections of computer –Secondary storage unit Long-term, high-capacity “warehouse” section Stores inactive programs or data Secondary storage devices –Hard drives, CDs, DVDs Slower to access than primary memory Less expensive per unit than primary memory

Computer Languages Three types of computer languages –Machine language Only language computer directly understands Generally consist of strings of numbers –Ultimately 0s and 1s Instruct computers to perform elementary operations Cumbersome for humans Example –

Computer Languages –Assembly language English-like abbreviations representing elementary computer operations Clearer to humans Incomprehensible to computers –Convert to machine language by translator programs (assemblers) Example loadbasepay add overpay store grosspay

Computer Languages –High-level languages Similar to everyday English –Uses common mathematical notations Single statements accomplish substantial tasks Compilers –Converted to machine language by translator programs Example –grossPay = basePay + overTimePay

History of C –Evolved from BCPL and B Developed by Dennis Ritchie (Bell Laboratories) –Development language of UNIX –Hardware independent Can write portable programs –ANSI and ISO standard for C published in 1990 ANSI/ISO 9899: 1990

History of C++ –Extension of C Developed by Bjarne Stroustrup (Bell Laboratories) in e arly 1980s –Provides new features to “spruce up” C –Provides capabilities for object-oriented programming Objects: reusable software components –Model items in the real world Object-oriented programs –Easier to understand, correct and modify

C++ Development Environment Microsoft Visual Studio 2005 (VS 2005) – 開始 → 程式集 →Microsoft Visual Studio 2005

Step 1 檔案 → 新增 → 專案 … (1) (2) (3) (4) (5)

Step 2 請尋找「方案總管」 ( 檢視 → 方案總管 ) – 在原始程式檔上右按滑鼠,選擇「加入 → 新增項目」

Step 3 選擇 (1) 程式碼, (2) C++ 檔,並 (3) 輸入檔名 (main.cpp) (1) (2) (3)

Step 4 在中央的編輯區中(上方會顯示你正編輯的檔名) 輸入程式:

Step 5 在編輯過程中,不要忘記存檔的動作(把存檔當習慣) 編譯並執行程式 –Ctrl+F5 (非偵錯模式) – 偵錯模式(可以追蹤出錯的程式碼) 編譯( compile ):把程式語言「翻譯」成機器指令碼。 執行( execute ):將機器指令碼載入記憶體, CPU 開始逐行 執行指令。

Note 如果在編譯的過程中,有出現錯誤,編譯器會指出錯誤 的位置;請仔細檢查拼字錯誤。 按「否」,以修 正錯誤 在錯誤上方點兩下,會顯示出錯誤發生「大約」的位置。

2.2 First Program in C++

Printing a Line of Text Ctrl+F5

Good Programming Practice Every program should begin with a comment that describes the purpose of the program. Use blank lines and space characters to enhance program readability. Lines beginning with “//” are comments.

The Basic Framework of a Program The main function is where a C++ program start to execute.

Statements –Note: Missing the semicolon at the end of a C++ statement is a syntax error. Instruct the program to perform an action All statements end with a semicolon (;)

Statements –std::cout Specifying cout is belongs to “namespace” std. –std::cout Standard output stream object. “Connected” to screen. –Stream insertion operator “<<“ Inserting right operand into left operand. Instruct the program to perform an action. All statements end with a semicolon (;)

String Constant String is composed of characters. A string constant is enclosed by double quotation marks ("). Escape characters –A character preceded by "\" Indicates “special” character output –Example "\n" welcometoc++!\n

Escape sequences.

More Examples of String Constants “Hello,\nWorld!” Hello, World! “Hello, World!\n” Hello, World! “My name is\nJoe.” My name is Joe.

Exercise