1 / 40

Computer programming 1 ( CS1301 )

Computer programming 1 ( CS1301 ). 1. Introduction to Computers, the Internet, World Wide Web, The Algorithms. OBJECTIVES. In this Chapter we will learn: 1.1 Introduction 1.2 Computers: What Is a Computer? 1.3 Computers: Hardware and Software? 1.4 Computer Organization

Download Presentation

Computer programming 1 ( CS1301 )

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer programming 1 (CS1301 )

  2. 1 Introduction to Computers, the Internet, World Wide Web, The Algorithms

  3. OBJECTIVES In this Chapter we will learn: 1.1 Introduction 1.2Computers: What Is a Computer? 1.3Computers: Hardware and Software? 1.4Computer Organization 1.5The Internet and the World Wide Web 1.6Machine Languages, Assembly Languages and High-Level Languages 1.7Programming Language, computer program and Computer Programmer 1.8 Program developing life cycle? 1.8.1 What do we mean by algorithm? 1.8.2 The Algorithms

  4. 1.1 Introduction -History of Computers: • 1950s: focus on efficient(كفاءة) automation of existing processes • 1960s: advent of 3GL, faster and more reliable(وثوقية واعتمادية) computers • 1970s: system development becomes more like an engineering discipline(انضباط)

  5. 1.1 Introduction • 1980s: major breakthrough with 4GL, CASE tools, object oriented methods • 1990s: focus on system integration, GUI (Graphical User Interface (applications, client/server platforms, Internet • The new century: Web application development, wireless PDAs (personal data assistant) , component-based applications

  6. 1.2 Computers: What Is a Computer? • Computers (often referred to as hardware) are controlled by software (i.e., the instructions you write to command the computer to perform actions and make decisions). So the computer is a device capable of performing computations and making logical decisions. • Today’s fastest supercomputers can perform thousands of trillions of instructions per second! • Computer programs • Sets of instructions that control computer’s processing of data. (Computers process dataunder the control of sets of instructions called computer programs). (the same definition) • Written by people called computer programmers. • Operating systems (Windows 7) • Application programs (Microsoft word)

  7. Hardware • Computer hardware is the collection of physical elements that constitutes a computer system and assist to the input, process, storage, output …. • Various devices comprising(تضم) computer • Keyboard, screen, mouse, disks, memory, CD-ROM, processing units, etc. • Software • Instructions to command computer to perform actions and make decisions. 1.3 Computers: Hardware and Software?

  8. 1.4 Computer Organization • Six logical units of computer • Input unit • “Receiving” section • Obtains Data from input devicesand places it at the disposal (تحت تصرف) of the other units so that it can be processed. • Keyboard, mouse, microphone, scanner, networks, etc. • Output unit • “Shipping” section • Takes information that the computer has processed and places it on various output devices to make it available for use outside the computer. • Screen, printer, networks, etc.

  9. 1.4 Computer Organization (Cont.) • Six logical units of computer (Cont.) • Memory unit • Retains(تحتفظ) Data that has been entered through the input unit, making it immediately available for processing when needed. It also retains processed information until it can be placed on output devices by the output unit. Information in the memory unit is volatile. The memory unit is often called either memory or primary memory. • Rapid access, relativelyنسبياً low capacity “warehouse” section • 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) • “Manufacturing” section • Performs arithmetic calculations and logic decisions

  10. 1.4 Computer Organization (Cont.) • Six logical units of computer (Cont.) • Central processing unit (CPU) • “Administrative” section • Coordinates and supervises the operation 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

  11. 1.4 Computer Organization (Cont.)Hardware Components

  12. 1.4 Computer Organization (Cont.)Hardware Components

  13. 1.4 Computer Organization (Cont.)Hardware Components in Actions Execution of an Instruction

  14. 1.5 The Internet and the World Wide Web • Internet • A collection of interconnected networks, all freely exchanging information. Or Global network of computers. • Initiated almost four decades (قرون) ago • Accessible by computers worldwide today • Internet has become one of the world’s premier (رائدة) communication mechanisms آليات • World Wide Web • Also called the Web, WWW, or W3 • Organizes Internet resources throughout the world into a series of menu pages, or screens, that appear on your computer. • Allows computer users to locate and view multimedia-based documents.

  15. 1.6 Machine Languages, Assembly Languages and High-Level Languages • Three types of computer languages • Machine language • Language of Computer. • Only language computer directly understands • “Natural language” of computer • Defined by hardware design Binary digit (bit): The digit 0 or 1 (عملية صعبة ومعقدة ومرهقة للبشر) Binary code: • A sequence of 0s and 1s Byte: • A sequence of eight bits.

  16. Early computers were programmed in machine language. To calculate wages= rates * hours in machine language 100100 010001 //load 100110 010010 // multiply 100010 010011 // store 1.6 Machine Languages, Assembly Languages and High-Level Languages

  17. 1.6 Machine Languages, Assembly Languages and High-Level Languages (Cont.) • Three types of computer languages (Cont.) -Assembly language Assembler: Translates a program written in assembly language in to machine language. • English-like abbreviations representing elementary computer operations • Clearer to humans • Incomprehensible (غير مفهومة) to computers • Example • load basepayadd overpaystore grosspay

  18. Assembly Language Examples of instructions in Assembly Language and Machine Language

  19. 1.6 Machine Languages, Assembly Languages and High-Level Languages (Cont.) • Three types of computer languages (Cont.) • High-level languages كتابة الأوامر بلغة مفهومة وسهلة وبسيطة أكثر مرونة • Include Basic, FORTRAN, COBOL, Pascal, C, C++, C# and Java • Similar to everyday English • Compiler: translates a program written in a high-level language in to machine language. • Uses common mathematical notations • The equation(معادلة) wages = rate* hours can be written in C++ as: Wages = rate * hours; • Another Example: • grossPay = basePay + overTimePay • Begin • A= 2 • B= 3 • C= A+B • Print C • If A > B then • Print A * B • End if • If A< B then • Print A-B • End if • End

  20. Programming is a process of problem solving • Programming Language: A set of rules, symbols and special words used to write computer program. عبارة عن مجموعة من الأوامر، تكتب وفق مجموعة من القواعد تحدد بواسطة لغة برمجة معينة، ومن ثم تمر هذه الأوامر بعدة مراحل إلى ان تنفذ على جهاز الحاسوب.تكمن أهميـة البرمجـة في عالم الحاسوب إلى أنها تسهل التعامل مع ال Hardware من خلال قيامها بدور الوسيط بين المستخدم و المكونات المادية. 1.7 Programming Language, Computer Program, and Computer Programmer

  21. A programmer, computer programmer, developer, coder, or software engineer is a person who writes computer software. • The term computer programmer can refer to a specialist in one area of computer programming or to a generalist who writes code for many kinds of software. Computer Programmer

  22. 1.8 What is program developing life cycle?

  23. step1: Analyze the problem. • أول خطوة تحليل المشكلة فهم المشكلة بصورة عامة وماهو المطلوب - Outline the problem and its requirements. - Design steps (algorithm) to solve the problem. • Step 2: Implement the algorithm. - Implement the algorithm code. - Verify that the algorithm works. • Step 3: Maintenance - Use and Modify the program if the problem domain changes. • Algorithm - Step – by – step problem solving processes عملية تنفيذ الحل خطوة خطوة 1.8 What is program developing life cycle?

  24. - step1: Analyze the problem. • Understand the overall problem. • Understand problem requirements. - Does program require user interaction? Example: When you calculate the area of ​​a rectangle What do we require from the user? Enter the length of the rectangle, width of the rectangle - Does program manipulate data? Example: Equation calculating the area of ​​a rectangle Area= length * Width - What is output? Note • If the problem is complex, divide into sub problems. • Analyze each sub problem as above. 1.8 The Problem Analysis- coding- Execution Cycle

  25. Algorithm - Step – by – step problem solving processes الخوارزمية هي عبارة عن الخطوات اللازمة لحل مسألة ما, و قد تكتب هذه الخوارزمية باللغة العربية أو الإنجليزيـة أو قد يعبر عنها برسم أشكال هندسيـة معينة. • وسُميت الخوارزمية بهذا الاسم نسبة إلى العالم المسلم أبو جعفر محمد بن موسى الخوارزمي الذي ابتكرها في القرن التاسع الميلادي. • فالخوارزمية تتضمن عنصريين هامين: • مجموعة من الخطوات. • ترتيب معين. 1.8.1 What do we mean by algorithm?

  26. 1.8 The Problem Analysis-Coding-Execution Cycle Stages of programming

  27. 1.8 The Problem Analysis-Coding-Execution Cycle

  28. 1.8.2 The Algorithm Methods for representing algorithms Pseudo code Flow Chart Note: Before use any two methods, you must specify the input, processing, and output

  29. Input(grade) If student's grade is greater than or equal to 60 Print "passed" else Print "failed" Pseudo CodeSimilar to the language of humans. Is not considered programming language. Can be easily converted for different programming languages ​​such as Pascal, Java, C++. Example 1: Using pseudo code ,write suitable algorithm: If the student's degree is greater than or equal 60, print “pass” else print “fail”. إذا كان الطالب معدله التراكمي أكبر من أو يساوي 60 اطبع ناجح و إلا اطبع راسب

  30. Example2: • Using Pseudo code, Write suitable algorithm: • If we want to calculate and print the average temperature, readings for the following three T1, T2, T3. Pseudo Code

  31. Input T1, T2, T3 • avg= (T1 + T2 + T3)/3 • Print avg Count the average of temperature Print the avg Answer 2: Input T1, T2, T3 Sum = (T1 + T2 + T3) Avg = sum/3 Print avg

  32. Is a way that explain the steps to resolve the issue or problem and how they relate to some by using symbols to explain the steps to the solution (a symbolic representation of the algorithm). Flow chart

  33. Flow chart Start or Stop Program Input or Output Process, Calculate, Storage Used to express logical operations or operations report (Condition) Arrows determine the direction of the program's progress Connection

  34. Example 3: • Using flow chart, Write suitable algorithm: • if we want to print the average temperature readings for the following three T1, T2, T3. Flow chart start Input T1, T2, T3 Input : T1, T2, T3 Processing : Sum = T1+T2+T3 Avg = sum/3 Output: Avg = sum/3 Sum = T1+T2+T3 Avg = sum/3 Print avg stop

  35. Example 4: • Using flow chart, Write suitable algorithm: • if we want to print the average temperature readings for the following three T1, T2, T3. • IF the average is greater than 15 print the average, else print the weather is cold. Flow chart start input T1, T2, T3 Sum= T1+T2+T3 Start Input T1,T2,T3 Sum = T1+T2+T3 Avg = sum/3 If avg > 15 then Print avg Else Print “cold” End if end Avg = sum/3 avg > 15 Print “cold” Print avg Stop

  36. Example 5: Write an algorithm for creating the program and print the value of the function F and x knowledge as follows: F= { x + 1 x >=0 x-1 x< 0 Flow chart

  37. Answer 5: start Input x Yes No X <=0 F = x-1 F= x+1 Print F , x End

  38. Write algorithm using pseudo code and flow chart for the introduction of 3 degrees and find the average temperature and print the "cool air“ if temperature less than 15, Print "moderate air” if temperature between 15 and 25, and print “hot air” if the temperature not verify the previous conditions. Discuss

  39. Write algorithm using pseudo code and flow diagram to calculate the area of ​​a rectangle print it.Note that the area of ​​the rectangle = length × width. • Write a program using the pseudo code and flow chart to find the area of ​​a circle which radius R print it.Note: The area of ​​a circle is equal to π * R2, where π is a constant value of approximately 3.14. • Using the methods (pseudo code and flow chart), we need to find and print the vicinity of the football stadium, and determine whether international (greater than or equal to 600 m) or local (less so), Note: The perimeter of the rectangle is equal to (length + width) × 2 . Home Work (1)

  40. End

More Related