Lecture 2: Flowcharts and Computer System PDF
Document Details
Uploaded by BeautifulTonalism3025
Zagazig University
Dr. Doaa El-Shahat
Tags
Related
- Csc 102: Introduction To Algorithm Techniques PDF
- GE8151- PROBLEM SOLVING AND PYTHON PROGRAMMING - Question Bank PDF
- CPRO1 Introduction to Computer Programming PDF
- Fundamentals of Algorithms and Flowcharts PDF 2020
- 104 CPPM Unit 1 Review/Revision PDF
- 3rd Grade Preparatory Computer and Information Technology Past Paper (2017/2018) PDF
Summary
This document provides a lecture on flowcharts and computer systems. It covers topics such as the definition and uses of flowcharts, along with the basic components of a computer system, hardware and software. Furthermore, it explains the fundamental data representation.
Full Transcript
Lecture 2 Computational thinking Dr. Doaa El-Shahat Computer Science, Zagazig university, Egypt Computer system Lecture 2 Algorithm representation (Flowcharts) LECTURE OBJECTIVES ❑ Flowcharts ❑ Standard flowchart symbols ❑ Rule...
Lecture 2 Computational thinking Dr. Doaa El-Shahat Computer Science, Zagazig university, Egypt Computer system Lecture 2 Algorithm representation (Flowcharts) LECTURE OBJECTIVES ❑ Flowcharts ❑ Standard flowchart symbols ❑ Rules for drawing flowcharts ❑ Computer system: hardware and software ❑ Data representation: ASCII and Unicode Flowcharts ❑ Flowchart is basically a pictorial or diagrammatic representation of an algorithm using standard symbols. ❑ It is a graphical representation that explains the sequence of operations to be performed in order to solve a problem under consideration. Standard flowchart symbols ❑ Various standard symbols are used to express different operations in the flowchart. ❑ All symbols are connected among themselves in order to show the flow of information and processing. ❑ Different symbols as prescribed by American National Standard Institute (ANSI). Standard flowchart symbols Rules for drawing a flowchart ❑ It should contain only one start and one end symbol. ❑ The relevant symbols must be used while drawing a flowchart ❑ The direction of arrows should be top to bottom and left to right ❑ It should be simple and drawn clearly ❑ Be consistent in using names, variables in the flow chart Start Flowchart for adding two numbers Read a and btwo Step 1: Start Sum=a+b Step 2: Read two numbers a and b Step 3: Calculate Sum = a + b Step 4: Print sum Print sum Step 5: stop Stop Start Calculation of simple interest Read P,T and Rtwo Algorithm : Calculation of Simple Interest Step 1: Start I = P*T*R/100 Step 2: Read principle (P), time (T) and rate (R) Step 3: Calculate I = P*T*R/100 Print I Step 4: Print I as Interest Step 5: Stop Stop Algorithm for find the greater number between two numbers. Step 1: Start Step 2: Read A and B Step 3: if A>B then Print A Step 4: Otherwise, print B Step 5: Stop Start Volume of a sphere Read rtwo Step 1: Start Step 2: Read r v = (4/3) * pi * r3 Step 3: Calculate v = (4/3) * pi * r3. Step 4: Print v Print v Step 5: Stop Stop Write an algorithm to find the factorial of a number N. Step 1: Start Step 2: Read N Step 3: Initialize F=1, i=1 Step 4: F = F * i Step 5: increment i by 1 Step 6: Repeat step 4 and step 5 until i=N Step 7: print F Step 8: Stop Write an algorithm to find sum of the integers from 1 to 100. Step 1: Start Step 2: Initialize count=1, sum=0 Step 3: sum = sum + i Step 4: increment i by 1 Step 5: Repeat step 3 and step 4 until i>100 Step 6: print sum Step 7: Stop Difference between algorithm, flowchart and program Note ▪ An algorithm is not a computer program. ▪ A computer program is an implementation of an algorithm. Computer system Hardware software Hardware ❑ It refers to the physical components that a computer is made of. ❑ A computer system consists of: 1.Central processing unit(CPU) 2.Main memory 3.Secondary storage devices 4.Input devices 5.Output devices Hardware Central Processing Unit (CPU) The CPU is used to: ▪ Fetch instruction. ▪ Decode the instruction. ▪ Execute instruction. Finally, CPU produces some result. Random Access Memory (RAM) ❑ CPU can quickly access data stored at any random location in RAM. ❑ RAM is temporary storage (if the computer is turned off, the contents of RAM are erased). ❑ RAM or memory is divided into small storage locations known as bytes. ❑ Each byte is assigned a unique number known as an address. Secondary storage Secondary storage is a type of memory that can hold data for long periods of time even when there is no power to the computer. The most common type of secondary storage device is the disk drive. Software ❑ There are two categories of software: ▪System software ▪Application software. Software 1. System software: programs that control and manage the basic operations of a computer ▪ Operating systems: windows, linux, Macintosh ▪ Utility programs: virus scanners, file-compression programs, and data-backup programs. ▪ Software development tools that programmers use to create, modify, and test software, such as compilers and integrated development environments. 2. Application Software make the computer useful for everyday task, Such as Microsoft Word, Web browsers and game programs Program ❑ A program is a set of instructions that a computer follows to perform a task. ❑It is stored in the computer’s main memory. ❑ A programming language is a special language used to write computer programs. ❑ A computer’s CPU can only process instructions that are written in a machine language (numbers consisting of only 1’s and 0’s) 1011010000000101 Programming language ❑ Easier to understand than machine language. ❑ Two categories of programming languages: ✓Low- level language is close to the machine language more than the natural language of human. ✓High-level language is closer to the level of human-readability. Popular programming languages Codes used for information exchange between computers ▪ A computer system understands only machine language (0, 1) in binary form. ▪ When you input any number or any alphabet or a special symbol, it must be converted into binary form. ▪ This form has to follow the coding standard. Some common coding standards are as follows: 1. ASCII 2. Unicode ASCII code ▪ Using ASCII codes, each alphabetic, numeric, or special character is represented with a 7-bit binary number (a string of seven 0s or 1s). ▪ Thus total 128 characters can be defined. 7 2 = 128 s 115 01110011 M 077 01001101 Letter ASCII Code Binary t 116 01110100 N 078 01001110 a 097 01100001 u 117 01110101 O 079 01001111 b 098 01100010 v 118 01110110 P 080 01010000 c 099 01100011 w 119 01110111 Q 081 01010001 d 100 01100100 x 120 01111000 R 082 01010010 e 101 01100101 y 121 01111001 S 083 01010011 f 102 01100110 z 122 01111010 T 084 01010100 g 103 01100111 A 065 01000001 U 085 01010101 h 104 01101000 B 066 01000010 V 086 01010110 i 105 01101001 C 067 01000011 W 087 01010111 j 106 01101010 D 068 01000100 X 088 01011000 k 107 01101011 E 069 01000101 Y 089 01011001 l 108 01101100 F 070 01000110 Z 090 01011010 m 109 01101101 G 071 01000111 n 110 01101110 H 072 01001000 o 111 01101111 I 073 01001001 p 112 01110000 J 074 01001010 q 113 01110001 K 075 01001011 r 114 01110010 L 076 01001100 Unicode, why? ▪ With a 32-bit Unicode, we can represent 232 characters in the computer memory. ▪ Before Unicode was invented, the character encodings were limited and could not contain enough characters to cover all the world’s languages. ▪ Unicode has been adopted by all modern software. Data representation ▪ Computers store data or information in the form of "1" and "0"s in different types of storages such as memory, hard disk, USB drives etc. ▪ Data Units Bit The smallest unit of data in a computer. A bit is a binary digit-either a 1 or 0. Byte A byte is a combination of eight bits. word Two bytes or sixteen bits Kilo Byte 1024 bytes or 1024x8 bits (1 KB). Mega Byte 1024 Kilo Bytes (1 MB). Giga Byte 1024 Mega Bytes (1 GB). Tera Byte 1024 Giga Bytes (1 TB). Peta Byte 1024 Tera Bytes (1 PB).