C++ Programming Chapter 1 Programming & Programs.

Slides:



Advertisements
Similar presentations
C++ Introduction.
Advertisements

Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 1 Engineering Problem Solving.
Introduction to Programming in C++ John Galletly.
CS105 INTRODUCTION TO COMPUTER CONCEPTS INTRO TO PROGRAMMING Instructor: Cuong (Charlie) Pham.
COSC 120 Computer Programming
CSE1301 Computer Programming Lecture 4: C Primitives I.
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex.
Three types of computer languages
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
C programming Language and Data Structure For DIT Students.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
Programming is instructing a computer to perform a task for you with the help of a programming language.
Introduction to Programming (in C++) Introduction Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
COMPUTER SCIENCE I C++ INTRODUCTION
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
Welcome In The World Of ‘C’.  TEXT BOOK: Programming in ANCI ‘C By: E Balagurusamy. TMH  Reference Books: 1) The ‘C Programming Language By: Kernighan.
High-Level Programming Languages: C++
Hello World 2 What does all that mean?.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Programming With C.
Chapter 1 Introduction to Computers and C++ Programming Goals: To introduce the fundamental hardware and software components of a computer system To introduce.
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1 Introduction to Computer and C++ Programming.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Chapter 6 Programming Languages (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
C Language: Introduction
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Computing Systems & Programming ECE Fundamental Concepts Chapter 1 Engineering Problem Solving.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Programming Languages
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
LESSON 1 Introduction to Programming Language. Computer  Comprised of various devices that are referred to as HARDWARE.  The computer programs that.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
小型系統 心情 vs. 古典樂 心情 vs. 古典樂 浪漫求籤系統 美食導航系統 季潔亭雅鈺熒岱芸 美食導航系統 楊氏音樂模擬大會考人瑋 若維 芷萱 伽倩 楊氏音樂模擬大會考 麥當勞熱量計算系統 火星文困擾你嗎 ? 火星文困擾你嗎 ? 歌詞知多少 - 挑戰你的腦容量英琪 日馨 青雪 鈺娟.
Software Engineering Algorithms, Compilers, & Lifecycle.
Programming Languages Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
CSE-102: PROGRAMMING FUNDAMENTALS LECTURE 3: BASICS OF C Course Instructor: Syed Monowar Hossain 1.
From Algorithms to Programs Both are sets of instructions on how to do a task Algorithm: –talking to humans, easy to understand –in plain (English) language.
Chapter 1 Introduction 2nd Semester H
Engineering Problem Solving With C An Object Based Approach
Chapter 1: Introduction to computers and C++ Programming
Computer Programming (BCT 1113)
Computer Programming Techniques Semester 1, 1998
C Programming Hardik H. Maheta.
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Welcome In The World Of ‘C’.  TEXT BOOK: Programming in ANSI ‘C By: E Balagurusamy. TMH  Reference Books: 1) The ‘C Programming Language By: Kernighan.
Computer science By/ Midhat Mohiey. Introduction to Programming using C ++ 2.
Hello World 2 What does all that mean?.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CS105 Introduction to Computer Concepts Intro to programming
The Programming Process
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
A programming language
C programming Language
Programs written in C and C++ can run on many different computers
CS105 Introduction to Computer Concepts Intro to programming
Presentation transcript:

C++ Programming Chapter 1 Programming & Programs

Chap01-2/ Program & algorithm What’s program? –Example in life game sourcecode sourcecode –A sequence of instructions –program = algorithm + data structure + programming methodology +languages How to describe algorithm 1.Natural language 2.Flowchart 3.Pseudocode: using a combination of natural language and programming language. A step-by-step procedure for solving a problem in a finite amount of time

Chap01-3/17 Example in Pseudo-code For a given value, Limit, what is the smallest positive integer Number for which the sum Sum = Number Sum = Number is greater than Limit. What is the value for this Sum ? Pseudocode: Input: An integer Limit Ouput: Two integers: Number and Sum Input: An integer Limit Ouput: Two integers: Number and Sum 1. Enter Limit 2. Set Number = Set Sum = Repeat the following: a. If Sum > Limit, terminate the repitition, otherwise. b. Increment Number by one. c. Add Number to Sum and set equal to Sum. 5. Print Number and Sum. Pseudocode: Input: An integer Limit Ouput: Two integers: Number and Sum Input: An integer Limit Ouput: Two integers: Number and Sum 1. Enter Limit 2. Set Number = Set Sum = Repeat the following: a. If Sum > Limit, terminate the repitition, otherwise. b. Increment Number by one. c. Add Number to Sum and set equal to Sum. 5. Print Number and Sum.

Chap01-4/ Programming language-1 Machine Code ---- The first generation language ( about in 1946 ) – M ade up of binary-coded instructions Machine Code Meaning load value from unit 20 to register A value of register A add value of unit 21 and put sum to register A store value of register A to unit program end

Chap01-5/ Programming language-2 Assembler the second generation language(early of 1950s) –Allow for the use of symbolic names instead of just numbers,such as load, store, add,etc. –Each new machine had its own assembler AssemblerMeaning LOAD X LOAD X load value from X load value from X ADD Y ADD Y X add Y X add Y STORE SUM STORE SUM store value to Sum store value to Sum HALT HALT program end program end

Chap01-6/17 Higher level language The third generation language (middle of 1950s) –Fortran born in 1956 –a classification by decribing problem, including procedural language,functional language, declarative language,OOP. TypeCharacteristic Classic Language procedual language step-by-step procedure FORTRAN,COBOL,ALGOL,BASIC,C, PASCAL,Ada,APL functional language composed by functionLISP,ML declarative language declarative language decribe what’s problemPROLOG,GPSS OOP based on object Smalltalk,C++,Visual Basic,Java 1.2 Programming language-3

Chap01-7/ Ada ALGOL60ALGOL68 Pascal Modula-2 CPLBCPLB C C++ Java LISP PROLOG COBOL FORTRAN77 FORTRAN PL/1 Simula 67 Smalltalk 80 BASIC ANSI-BASIC QBASIC VB FORTRAN90

Chap01-8/17 the fourth generation language ( 1980s ) –a programming language or programming environment designed with a specific purpose in mind, such as the development of commercial business software. –Including: SQL, report-generator, GUI creators, application generator, more higher level language, application software package etc. Example : SELECT name,department,teaching_age FROM d:\zg.dbf WHERE teaching_age >= Programming language-4

Chap01-9/17 Types of program –Source program: a program written in advanced programming language. –Object program: the machine language version of a source program –Compiler: a program that translates an advanced programming language into machine language. 1.2 Programming language-5

Chap01-10/17 C++ Language history 1.2 Programming language-6 CPLBCPLB C99 C++ C89 Classic C C++98 Christopher Strachey, Cambridge, mid-1960s Martin Richards, Cambridge, 1967 Ken Thompson, BTL, 1972 Dennis Ritchie, BTL, 1974 C++0x Bjarne Stroustrup, BTL, 1985

Chap01-11/17 //1-1.cpp The first C++ Program 1#include 2using namespace std; 3 int main( ) 4 { 5cout<<“Hello, World!\n”; 6 7 return 0; 8 } //get the library facilities needed for now // main() is where a C++ program starts //function begin //function end Example 1-1 The first program Hello, World! 1.3 Basic Framework of C++ Program -1 // output the 13 characters Hello, world! // followed by a new line // return a value indicating success //comment

Chap01-12/ Basic Framework of C++ Program -2 //1-2.cpp 1 #include 1 #include 2 #include 2 #include 3 using namespace std; 4 int main( ) 5 { 6 float a,b; 7 b=30.0; 8 a=sin(b* /180); 9 cout<< “ a= “ <<a<<endl; 10 return 0; 11 } //Define variable //assign value to b //assign value calculating sin to a

Chap01-13/ Basic Framework of C++ Program -3 Pre-process command int main( ) { //function begin declarations; //define variable declarations; //define variable executions ; //input,assignment, calculate, control,output etc. executions ; //input,assignment, calculate, control,output etc. return 0; return 0; } //function end

Chap01-14/17 –Function and main function A C++ program is a collection of one function or more functions, each function performs some particular task.A C++ program is a collection of one function or more functions, each function performs some particular task. Every C++ program must have a function named main.Every C++ program must have a function named main. Excecution of the program always begins with the main function. You can think of main as the master and the other functions as the servants.Excecution of the program always begins with the main function. You can think of main as the master and the other functions as the servants. –Program statement A C++ program is composed by statements;A C++ program is composed by statements; using “;” as ending of statementusing “;” as ending of statement –Comment Using “//” as commentUsing “//” as comment don’t generate compiling codedon’t generate compiling code 1.3 Basic Framework of C++ Program – Summary

Chap01-15/ Compilation and linking You write C++ source code –Source code is (in principle) human readable The compiler translates what you wrote into object code (sometimes called machine code) –Object code is simple enough for a computer to “understand” The linker links your code to system code needed to execute –E.g. input/output libraries, operating system code, and windowing code The result is an executable program –E.g. a.exe file on windows or an a.out file on Unix C++ compiler C++ source code Object code linker Executable program Library Object code

Chap01-16/17 Key Points To master what’s program. To understand what’s algorithm. To undestand what’s framework of a C++ program. To understand how to translate into machine code.

Chap01-17/17 Exercises 1 、 Write a program to output your code and your name.