Introduction عزيزتي الطالبة : يهدف هذا المبحث من تمكينك من التعرف الى مفهوم لغات البرمجة وتعلم أسياسيات لغة البرمجة من خلال دراسة أجزاء من لغة C++ وكتابة.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

 Computer hardware components are the physical pieces of the computer.  The major hardware components of a computer are: – The central processing.
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
COSC 120 Computer Programming
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
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.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
CS102 Introduction to Computer Programming
Introduction to Computers and Python. What is a Computer? Computer- a device capable of performing computations and making logical decisions at speeds.
Tools make jobs easier to do -A computer is a tool used by many professions A computer can do many different jobs because they are programmable - Machine.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
Introduction to Programming Dr Masitah Ghazali Programming Techniques I SCJ1013.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Introduction to Programming. Our Book in CS Why Program? Lets watch a video
Topics Introduction Hardware and Software How Computers Store Data
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Chapter 1 Introduction to Computer and Java 1. Contents 1.Introduction 2.Why Program? 3.Computer Systems: Hardware and Software 4.Programming Languages.
Copyright © 2012 Pearson Education, Inc. Chapter 1 Introduction to Computing and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming.
Introduction to Computer Systems and the Java Programming Language.
Chapter 1: An Overview of Computers and Programming Languages
Overview of Programming and Problem Solving Textbook Chapter 1 1.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Mrs. Ulshafer August, 2013 Java Programming Chapter 1.
1 12/4/1435 h Lecture 2 Programs and Programming Languages.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
A.Abhari CPS1251 Topic 1: Introduction to Computers Computer Hardware Computer components Connecting Computers Computer Software Operating System (OS)
Computer Programming (1) Code & No.: CS 102 CREDIT HOURS: 5 UNIT Lecture 3.0 hours/week Lab: 2.0 hour/on every week a. This course introduces the students.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming Dr. Halla Abdel Hameed.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Introduction to Computers and Computing.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Introduction to Programming. Key terms  CPU  I/O Devices  Main memory  Secondary memory  Operating system  User interface  Application  GUI 
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming
BASIC PROGRAMMING C SCP1103 (02)
Chapter 1: An Overview of Computers and Programming Languages
Engineering Problem Solving With C An Object Based Approach
Microsoft Imagine All KU students currently enrolled in a CS class are eligible to receive Microsoft software, including Operating Systems development.
Topics Introduction Hardware and Software How Computers Store Data
Chapter 1: An Overview of Computers and Programming Languages
BASIC PROGRAMMING C SCP1103 (02)
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Chapter 1: Introduction to Computers and Programming
Topics Introduction Hardware and Software How Computers Store Data
Chapter 1: Introduction to Computers and Programming
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Introduction عزيزتي الطالبة : يهدف هذا المبحث من تمكينك من التعرف الى مفهوم لغات البرمجة وتعلم أسياسيات لغة البرمجة من خلال دراسة أجزاء من لغة C++ وكتابة البرامج باستخدام هذه اللغة والتي من خلالها سيتكون عندك قاعدة أسياسية لعلم البرمجة والانطلاق للتعلم والابداع في أي لغة برمجة اخرى. ما نحتاجه في هذا المبحث : تنزيل برمجية visual c كتاب "c++ how to program by Harvy m. Deitel. and paul J Detil ",seventh edition كتاب الكتروني ( مراسلتي على أي مرجع آخر في لغة C++ باللغة العربية او الانجليزية او مواقع الانترنت

Introduction to Computers and Programming 1-2

Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer – person who writes instructions (programs) to make computer perform a task SO, without programmers, no programs; without programs, a computer cannot do anything 1-3

Why programming? programmers must learn special languages, because computers do not understand English or other human languages 1-4

physical components that make up a computer 1. Central Processing Unit (CPU) 2. Main Memory 3. Secondary Memory / Storage 4. Input Devices 5. Output Devices 1-6

1-7 Figure 1-1

Comprised of:  Control Unit Retrieves and decodes program instructions Coordinates activities of all other parts of computer  Arithmetic & Logic Unit Hardware optimized for high-speed numeric calculation Hardware designed for true/false, yes/no decisions Where are instructions & data stored? Registers 1-8

1-9

It is volatile. Main memory is erased when program terminates or computer is turned off Also called Random Access Memory (RAM) Organized as follows:  bit: smallest piece of memory. Has values 0 (off, false) or 1 (on, true)  byte: 8 consecutive bits. Bytes have addresses.  addresses : Each byte in memory is identified by a unique number known as an address  Word :Usually 4 consecutive bytes has an address 1-10

1-11 In Figure 1-3, the number 149 is stored in the byte with the address 16, and the number 72 is stored at address 23.

The CPU's Role in Running a Program : Machine/Execution CYCLE Fetch: get the next program instruction from main memory, copy into CPU. Decode: interpret the instruction and generate a signal. Execute: route the signal to the appropriate component to perform an operation. 1-12

Non-volatile: data retained when program is not running or computer is turned off Comes in a variety of media: magnetic: floppy disk, hard drive optical: CD-ROM, DVD Flash drives, connected to the USB port 1-13

Devices that send information to the computer from outside Many devices can provide input: Keyboard, mouse, scanner, digital camera, microphone Disk drives, CD drives, and DVD drives 1-14 Output Devices :Output is information sent from a computer program to the outside world. The output is sent to an output device Disk drives Writable CD and DVD drives Computer monitor and printer

Categories of software: Operating system: programs that manage the computer hardware and the programs that run on them. Examples: Windows, UNIX, Linux Application software: programs that provide services to the user. Examples : word processing, games, programs to solve specific problems 1-15

A program : is a set of instructions that the computer follows to perform a task We start with an algorithm, which is a set of well- defined steps. Programming Language : a language used to write programs 1-17

For example, suppose we want the computer to calculate someone’s gross pay. What is a list of things the computer might do: 1-18

The computer only executes machine language instructions. Machine language :instructions are binary numbers, such as Rather than writing programs in machine language, programmers use programming languages. 1-19

Low-level: used for communication with computer hardware directly. Often written in binary machine code (0’s/1’s) directly. High-level: closer to human language 1-20

1-21 BASIC FORTRAN COBOL C C++ C# Java JavaScript Python Ruby Visual Basic

a) Create file containing the program with a text editor. b) Run preprocessor to convert source file directives to source code program statements. c) Run compiler to convert source program into machine instructions. d) Run linker to connect hardware-specific code to machine instructions, producing an executable file.  Errors detected at any step will prevent execution of following steps. 1-22

1-23 Source Code Preprocessor Modified Source Code Compiler Object Code Linker Executable Code

An integrated development environment, or IDE, combine all the tools needed to write, compile, and debug a program into a single software application. Examples are Microsoft Visual C++, Turbo C++ Explorer, CodeWarrior, etc. 1-24

1-25

ASCII Code Character code consisting or 8 (7) bits See Appendix A (page 1141) A B A Others: EBCDIC, Unicode 1-26

Common elements in programming languages: Key Words Programmer-Defined Identifiers Operators Punctuation Syntax 1-28

1 // This program calculates the user's pay. 2 #include 3 using namespace std; 4 5 int main() 6 { 7 double hours, rate, pay; 8 9 // Get the number of hours worked. 10 cout > hours; // Get the hourly pay rate. 14 cout > rate; // Calculate the pay. 18 pay = hours * rate; // Display the pay. 21 cout << "You have earned $" << pay << endl; 22 return 0; 23 } 1-29

Also known as reserved words Have a special meaning in C++ Can not be used for any other purpose Key words in the Program 1-1: using, namespace, int, double, and return. 1-30

1 // This program calculates the user's pay. 2 #include 3 using namespace std; 4 5 int main() 6 { 7 double hours, rate, pay; 8 9 // Get the number of hours worked. 10 cout > hours; // Get the hourly pay rate. 14 cout > rate; // Calculate the pay. 18 pay = hours * rate; // Display the pay. 21 cout << "You have earned $" << pay << endl; 22 return 0; 23 } 1-31

Names made up by the programmer Not part of the C++ language Used to represent various things: variables (memory locations), functions, etc. In Program 1-1: hours, rate, and pay. 1-32

1 // This program calculates the user's pay. 2 #include 3 using namespace std; 4 5 int main() 6 { 7 double hours, rate, pay; 8 9 // Get the number of hours worked. 10 cout > hours; // Get the hourly pay rate. 14 cout > rate; // Calculate the pay. 18 pay = hours * rate; // Display the pay. 21 cout << "You have earned $" << pay << endl; 22 return 0; 23 } 1-33

Used to perform operations on data Many types of operators: Arithmetic - ex: +,-,*,/ Assignment – ex: = Some operators in Program1-1: > = * 1-34

1 // This program calculates the user's pay. 2 #include 3 using namespace std; 4 5 int main() 6 { 7 double hours, rate, pay; 8 9 // Get the number of hours worked. 10 cout > hours; // Get the hourly pay rate. 14 cout > rate; // Calculate the pay. 18 pay = hours * rate; // Display the pay. 21 cout << "You have earned $" << pay << endl; 22 return 0; 23 } 1-35

Characters that mark the end of a statement, or that separate items in a list In Program 1-1:, and ; 1-36

1 // This program calculates the user's pay. 2 #include 3 using namespace std; 4 5 int main() 6 { 7 double hours, rate, pay; 8 9 // Get the number of hours worked. 10 cout > hours; // Get the hourly pay rate. 14 cout > rate; // Calculate the pay. 18 pay = hours * rate; // Display the pay. 21 cout << "You have earned $" << pay << endl; 22 return 0; 23 } 1-37

Lines vs. Statements A line is all of the characters entered before a carriage return. Blank lines improve the readability of a program. Here are four sample lines. Line 3 is blank: double num1 = 5, num2, sum; num2 = 12; sum = num1 + num2 1-38

In a source file, A statement is an instruction to the computer to perform an action. A ; indicates the end of a statement A statement may contain keywords, operators, programmer- defined identifiers, punctuation. A statement may fit on one line, or it may occupy multiple lines. Here is a single statement that uses two lines: double num1 = 5, num2, sum; 1-39

The rules of grammar that must be followed when writing a program Controls the use of key words, operators, programmer- defined symbols, and punctuation 1-40

A variable is a named storage location in the computer’s memory for holding a piece of data. It must be defined before it can be used In Program 1-1 we used three variables: The hours variable was used to hold the hours worked The rate variable was used to hold the pay rate The pay variable was used to hold the gross pay 1-41

Three steps that a program typically performs: 1) Gather input data: from keyboard from files on disk drives 2) Process the input data 3) Display the results as output: send it to the screen write to a file 1-43

The Programming Process 1. Define what the program is to do. 2. Visualize the program running on the computer. 3. Use design tools to create a model of the program. 4. Check the model for logical errors. 5. Write the program source code. 6. Compile the source code 7. Correct any errors found during compilation. 8. Link the program to create an executable file. 9. Run the program using test data for input. 10. Correct any errors found while running the program Validate the results of the program. 12. Does the program do what was defined in step 1? 1-44

Correct any errors found during compilation. 8. Link the program to create an executable file. 9. Run the program using test data for input. 10. Correct any errors found while running the program. Repeat steps as many times as necessary. 11. Validate the results of the program. Does the program do what was defined in step 1?

Homework 1. Describe the difference between a key word and a programmer- defined identifier 2. Describe the difference between operators and punctuation symbols. 3. Why must programs written in a high-level language be translated into machine language before they can be run 4. Fill-in-the-Blank A. Internally, the CPU consists of the __________ and the __________. B. A(n) __________ is an example of a secondary storage device. C. The two general categories of software are __________ and __________. D. A program is a set of __________. E. Since computers can’t be programmed in natural human language, algorithms must be written in a(n) __________ language. F. __________ is the only language computers really process. G. __________ languages are close to the level of humans in terms of readability. H. __________ languages are close to the level of the computer. 1-46