Presentation is loading. Please wait.

Presentation is loading. Please wait.

Overview of a Computer System Fundamentals of Programming Chapter 1.

Similar presentations


Presentation on theme: "Overview of a Computer System Fundamentals of Programming Chapter 1."— Presentation transcript:

1 Overview of a Computer System Fundamentals of Programming Chapter 1

2 Memory Input CPU Arithmetic /Logic Unit Output

3 Programming Programming is providing a computer a set of instructions to perform.

4 Program Program is a set of instructions for a computer to perform.

5 Programmer Programmer is a person who writes the set of instructions.

6 A sample program (written in the English language) A sample program (written in the English language) 1) Accept three numbers from the keyboard 2) Store these numbers in the memory 3) Name the memories A, B and C correspondingly 4) Add the three numbers

7 A sample program (written in the English language) A sample program (written in the English language) 5) Store the result of the addition in memory 6) Name the memory where the sum is stored as D 7) Print on the computer screen the result stored in D

8 Programming Language Programming Language is the language used in writing a set of instructions for the computer to follow.

9 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages Assembler Name: Assembly Language Created: 1956 – 1963 By: IBM Language type: low level

10 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages Lisp Name: Lisp Created: 1956 By: John McCarthy Acronym: List Processing Language type: Functional

11 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages Fortran Name: Fortran Created: 1957 By: IBM, John Backus Acronym: Formula Translation Language type: block-structured

12 Timelines of Popular Computer Programming Languages Cobol Name: Cobol Created: 1959 By: Conference on Data Systems Languages Acronym: Common Business Oriented Language Language type: block-structured

13 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages Basic Name: Basic Created: 1964 By: John George Kemeny & Tom Kurtz Acronym: Beginners All-purpose Symbolic Instruction Code Language type: block-structured

14 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages Pascal Name: Pascal Created: 1970 By: Professor Niklaus Wirth Acronym: Language type: block-structured

15 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages C-language Name: C Created: 1972 By: Bell Laboratories Acronym: Language type: block-structured

16 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages C++ Name: C++ Created: 1983 - 1985 By: Bjarne Stroustrup at Bell Labs Acronym: Language type: Object-oriented

17 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages QBasic Name: QBasic Created: 1986 By: Microsoft Acronym: QuickBasic Language type: block-structured

18 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages Perl Name: Perl Created: 1987 By: Larry Wall Acronym: Language type: Command or Scripting

19 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages Visual Basic Name: Visual Basic Created: 1991 By: Microsoft Acronym: Language type: block-structured

20 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages Java Name: Java Created: 1995 By: James Gosling Acronym: Language type: Object-oriented

21 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages JavaScript Name: JavaScript Created: 1995 By: Netscape Communications Corp. & Sun Microsystems Acronym: Language type: Command or Scripting

22 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages VBScript Name: VBScript Created: 1997 By: Microsoft Acronym: Visual basic Scripting Edition Language type: Application/Macro

23 Timelines of Popular Computer Programming Languages Timelines of Popular Computer Programming Languages VBScript Name: VBScript Created: 1997 By: Microsoft Acronym: Visual basic Scripting Edition Language type: Application/Macro

24 Steps in Programming Steps in Programming 1. Definition of the Problem 2. Analysis of the Problem 3. Coding the Program 4. Debugging & Testing the Program 5. Documenting the Program

25 Defining the Problem Chapter 2

26 Stating the Problem Stating the Problem Problem 1: Write a program to determine the sum of two numbers. Problem 2: Write a program that will compute the area of a circle.

27 Definitive Statement of the Problem Definitive Statement of the Problem Problem 1: Give the computer two numbers. It should be able to add the two numbers and give the result.

28 Definitive Statement of the Problem Definitive Statement of the Problem How will you re-state Problem No 2?

29 Analyzing the Problem Analyzing the Problem NATURE. (What is it about) SCOPE. (Limitations)

30 Example 1 Example 1 Problem 1: Write a program to determine the sum of two numbers. Nature: Mathematical Scope: Limit the scope to numbers that are integers or whole numbers.

31 Example 2 Example 2 Problem 2: Write a program that will compute the area of a circle. Nature: Geometry. Scope: Allow fractions and decimals as acceptable values. No negative values for the radius should be accepted.

32 Identifying the Output Identifying the Output Problem 1: Write a program to determine the sum of two numbers. Output: [sum] The sum of the two numbers you gave is: [sum]

33 Identifying the Input Identifying the Input Problem 1: Write a program to determine the sum of two numbers. Input: We need two numbers as the input. (keyed in the keyboard)

34 Identifying the Input Identifying the Input Problem 2: Write a program that will compute the area of a circle. Input: Radius (to be entered from the keyboard)

35 Defining the Process Defining the Process Problem 1: Write a program to determine the sum of two numbers. Process: Enter two numbers using the keyboard. The computer must be able to reject fractions and decimal numbers. The computer will then add the two numbers. The result of the addition will be displayed on the computer screen.

36 Defining the Process Defining the Process Problem 2: Write a program that will compute the area of a circle. Process: The program must be able to accept a number representing the radius. The computer should make it sure that no negative number will be entered. The computer must compute the area of the circle. Result must be displayed on the screen.

37 Exercise #1 Exercise #1 Analyze the given problem for using the five-step procedure you learned from this chapter. Problem: Write a program to determine the average of three numbers.

38 Exercise #2 Exercise #2 Analyze the given problem for using the five- step procedure you learned from this chapter. Problem: Write a program to determine whether a number entered on the keyboard is odd or even.

39 Exercise #3 Exercise #3 Analyze the given problem for using the five-step procedure you learned from this chapter. Problem: Generate the first ten positive numbers. For each number, print its square and cube.

40 Planning the Solution ICT Programming 1 Chapter 3

41 Algorithm A set of rules for solving a problem in a finite number of steps.

42 Overview of an Algorithm STEPS IN COOKING SCRAMBLED EGG 1) Prepare all necessary items needed (egg, pan, oil etc.) 2) Beat the egg 3) Add salt 4) Heat pan 5) Put oil into the pan

43 Overview of an Algorithm STEPS IN COOKING SCRAMBLED EGG 6) Pour beaten egg if pan is already hot enough 7) Cook egg for at least two minutes 8) Serve Egg

44 Control Structures Structured programming  is a technique that emphasizes thebreaking of a program or algorithm into logical sections, or modules following a universal programming standard. (Breaking of programs into smaller modules)

45 Control Structures is a step, or a series of steps, that determines what instructions or set of instructions will be done nest. Three Basic Structures  Sequential  Selection  Iteration

46 Sequential is the most straight forward. The program will just follow the instructions one after the other in a sequential manner. Process 1 Process 2

47 Example: Taking a Bath Turn on the Shower Dry yourself with towel Get yourself wetGet the Bath Soap Rub it on your bodyMassage it on hair Rinse your hair and Body Put on New Clothes

48 Selection Let your program or algorithm make a decision. Choose one from two sets of instructions depending on the condition. IF (condition) THEN (Process 1) ELSE (Process 2)

49 Process 2 Process 1 IF Condition

50 IF (it is dark) THEN (turn on the lights) ELSE (do not turn on the lights) Do not turn on the lights Turn on the Lights Is it dark? True False

51 Iteration We use when we want our algorithm or program to repeat a process a specified number of times. The structure that repeats an instruction or a set of instructions until a condition is met is known as iteration or loop.

52 Process 1 Is the condition met? Yes No Iteration

53 Whether the scrambled egg is ready to be served or not Beat the egg Add salt Place the pan in the stove Put on the stove Pour cooking oil Heat the oil Put egg Cook: { here is the example of the control structure} Heat the egg IF the egg is done THEN serve the egg ELSE goo to Cook {End pf control structure}

54 Serve the egg Is egg done? Yes No Iteration control for serving scrambled egg Cook Heat the egg

55 Flowcharting  is one method of pictorially representing a procedural (step-by-step) solution to a problem before you actually start to write the computer instructions required to produce the desired results.

56 Two Types of Flowchart  System (data) flowcharts  Programming flowcharts

57 System Flowchart  Defines the major phases of the processing, as well as the various data media used.  It shows the relationship of numerous jobs that make up an entire system.

58 Example of system flowchart Process Payroll Pay Records Pay Check

59 Programming Flowchart  Constructed by the programmer to represent the sequence of operations the computer is to perform to solve a specific problem.  It graphically describes what is to take place in the program.

60 Standard Symbols Start or end of a program Input or Output Operation Computational steps or processing function of a program Alternate Process Decision-Making and Branching Connector Preparation or Initialization Off-page connector Magnetic tape Magnetic Disk Display Flow line

61 Examples on Flowcharting Problem: Make a flowchart to determine the sum of two numbers. Definitive Statement: Give the computer two numbers. It should be able to add the two numbers and give the result.

62 Examples on Flowcharting Output: [sum] or The sum of the two numbers is: [sum] Input: we need two numbers as the input. The program allows both positive and negative integers.

63 Sum = N1 + N2 Input N1 Output Sum Start the process Start Input N2 End Input N1, N2 Enter the 1st no called N1 Enter the 1st no called N2 N1 and N2 is added and the result is called Sum Sum is given as the output End of the process The two blocks can be combined as Example 1

64 N = N + 1 Print Sum Start End Example 2 Sum = 0 N = 0 Sum = Sum + N Is N = 50? Yes No Draw a flowchart to find the sum of first 50 natural numbers.

65 Print A Start End Example 3 Draw a flowchart to find the largest of three numbers A, B and C. Read A, B, C Is A>B? Yes Is A>C? Yes No Print C No Is B>C? Yes Print B

66 Pseudocode  Uses words and mathematical expressions to represent the logic, or the flow of the program.  Informal language for writing algorithms.

67 NOTATIONUSEOTHER NOTATIONS USED INPUTUsed when reading or entering data in any of the input devices. READ, ENTER OUTPUTUsed when we wish a value to be displayed. WRITE, DISPLAY, PRINT BEGINMarks the start of a pseudocode. START ENDMarks the end of a pseudocode. STOP, HALT  Storage Operator. Used to indicate that a value is stored in a memory location.

68 Example of Pseudocode Problem: Write a pseudocode to determine the sum of two numbers. Definitive Statement: Give the computer two numbers. It should be able to add the two numbers and give the result.

69 Example of Pseudocode Output: The output of the computer should give us a number which is integer or a whole number. [sum] or The sum of the two numbers you gave is: [sum]

70 Example of Pseudocode Pseudocode: BEGIN INPUT the first number INPUT the seocnd number Add the two numbers OUTPUT the sum END

71 Equivalent Code in C++ { cin>>N1; cin>>N2; Sum=N1 + N2; cout<<Sum; }

72 VALID IDENTIFIERSINVALID IDENTIFIERS sum123 N14abc rs232c2nd salary#ars X Y

73 Problem 2: Make a pseudocode to enter two numbers. Display their sum if the first number is less than the second number entered, otherwise, display their average.

74 Solution: Pseudocode: INPUT A INPUT B Sum  A + B Ave  Sum / 2 IF (A>B) THEN (Output Sum) ELSE (Output Ave) END

75 Problem 3: Make a pseudocode to determine whether a number is even or odd.

76 Solution: Pseudocode: BEGIN INPUT N Divide N by 2 IF(there is remainder) THEN (output “Number is Odd”) ELSE (output “Number is Even”) END

77 Flowcharting & Pseudocoding Exercises 1) Read three numbers, add them, print the result and end the procedure. 2) Read two numbers, multiply them, print the result and end the procedure. 3) Read two numbers, divide the second by the first and print the quotient.

78 Pseudocode for Exercise #1 1) Read three numbers, add them, print the result and end the procedure. BEGIN INPUT A, B, C Sum  A + B + C OUTPUT Sum END

79 Flowchart for Exercise #1 1) Read three numbers, add them, print the result and end the procedure. START Read A, B, C Sum = A + B + C Write Sum STOP

80 Pseudocode for Exercise #2 2) Read two numbers, multiply them, print the result and end the procedure. BEGIN INPUT A, B Product  A * B OUTPUT Product END

81 Flowchart for Exercise #2 2) Read two numbers, multiply them, print the result and end the procedure. START Read A, B Product = A * B Write Product STOP

82 Pseudocode for Exercise #3 3) Read two numbers, divide the second by the first and print the quotient. BEGIN INPUT A, B Quotient  B / A OUTPUT Quotient END 2) Read two numbers, multiply them, print the result and end the procedure.

83 Flowchart for Exercise #3 3) Read two numbers, divide the second by the first and print the quotient. START Read A, B Quotient = B / A Write Quotient STOP

84 Seatwork for Today (20 pts) Given two variables A and B where A=7 and B=5 Make a Pseudocode or a Flowchart (choose just one!)that swaps the content of A and B and display on screen the new values of A and B. Expected Output: A is 5 B is 7


Download ppt "Overview of a Computer System Fundamentals of Programming Chapter 1."

Similar presentations


Ads by Google