Flowchart Basics

Embed Size (px)

Citation preview

  • 8/8/2019 Flowchart Basics

    1/17

    Kaushlendra Pratap Singh Flowchart Basics

    FUNDAMENTALS

    OFPROGRAMMING

    (USING FLOWCHARTS)

    Kaushlendra Pratp Singh

  • 8/8/2019 Flowchart Basics

    2/17

    Kaushlendra Pratap Singh Flowchart Basics

    Index

    Chapter 1 -Basics of Computers ................................................................... 3

    Computers are classified in categories / shapes : ................................. 5 Parts of Information System : ........................................................... 5 Operations in ALU: .......................................................................... 8

    Chapter 2 - Data Representation & Data Communication ........................... 10

    Introduction : ............................................................................... 10 Data Communication & Networking : ............................................... 11 Features of Networking .................................................................. 11 Types of Networks ......................................................................... 11

    Chapter 3 - Flowcharts Elementary Concepts .......................................... 14

    Introduction .................................................................................. 14 Types of Flowcharts ....................................................................... 14 Symbols used in Flowcharts ............................................................ 15 Advantages of using flowcharts ....................................................... 16 Limitations of using flowcharts ........................................................ 16 Constants and Variable................................................................... 16

  • 8/8/2019 Flowchart Basics

    3/17

    Kaushlendra Pratap Singh Flowchart Basics

    Chapter 1 -Basics of Computers

    Introduction :

    It is a truly amazing machine. It is an electronic device used to process data. In

    1940s & 1950s computers were of massive size used by big institutions, govt.offices, military & universities.

    Computer is derived from the word Compute which means to calculate. As they canstore, process & retrieve data ,as and when required they are also known as Data

    Processor. eg. : ENIAC , UNIVAC etc.

    Historical development of Computer :

    Around 3000 BC in China a computer called Abacus was developed which used

    beads to represent decimal & arithmetic operations of smaller volume can be

    performed with its help. Number of improvements were made till the Stepped-Wheel calculator was invented which multiplied & divided directly.

    In 1822, Charles Babbage of England proposed the Differential Enginewhich was refined to Analytical Engine in 1833, which became the firstcompletely automatic general purpose digital computer.

    Punched card (Mark I) was invented in 1943 in Harvard University. The

    original computer weighed about five tons. In operation, it was fed instructions thatwere coded in the form of holes punched in a narrow paper tape or a punched papercard.

    ENIAC : Electronic Numerical Integrator & Calculator was designed in the year

    1945 which contained 18000 vaccum-tubes, weighed 30 tons which occupied 1500sq.ft. space & just 200 characters memory by J. Presper Eckert & John W. Mauchly atPennsylvania in Philadelphia.

    EDVAC : Electronic Discrete Variable Automatic Computer was developed inthe year 1951 by J. Presper Eckert, John W. Mauchly & Jon Von Neuman for storingdata which used the Binary Number System.

    UNIVAC : Universal Automatic Computer was developed by Remington Rand inthe year 1951.

    Generations of Computers :

    1> First Generation ( 1942 1955 ) :-

    a) Physically large in size.

    b) Rigid in operations.

    c) Limited memory & computing capacity.d) Slow operating speed i.e. ( in milli seconds )

  • 8/8/2019 Flowchart Basics

    4/17

    Kaushlendra Pratap Singh Flowchart Basics

    e) Contained Vaccum Tubes.f) Restricted programming capabilities.

    g) Generated more heat.

    h) Very high maintenance problems.i) Very expensive.

    2> Second Generation ( 1955 1964 ) :-

    a) Considerable reduction in physical size.

    b) Comparatively more reliable.c) Comparably large memory.d) Greater operating speed i.e. ( in micro seconds )

    e) Contained transistors as basic component & consumed less power.f) Improved computing capacity.

    g) Generated less heat as compared to first generation..

    h) Faster & better input output devices.

    3> Third Generation ( 1964 1975 ) :-

    a) Greater miniaturization.b) Flexible in operation.

    c) Larger memory.

    d) High operating speed i.e. ( in nano seconds )e) Contained Integrated Circuits.

    f) Very reliable & Random Access possible.

    g) Time sharing & Multi Processing.

    h) Compatible with other softwares.i) High level languages like FORTRAN & COBOL came into existence.

    4> Fourth Generation ( 1975 onwards ) :-

    The advancement in the electronics could pack thousands of components intovery small assemblies known as LSI ( Large Scale Integration ) & it led to

    the fourth generation of computers. Micro processor was developed where

    an entire CPU was accommodated on a single chip. Intel 4004 was the firstmicroprocessor which was further updated to Intel 8080 & this led to usage of

    Personal Computers.

    5> Fifth Generation ( Future computers ) :-

    Here computer systems have been thought of using Artificial Intelligence &Parallel Processing Hardware. Knowledge based expert systems would bethe main feature.

  • 8/8/2019 Flowchart Basics

    5/17

    Kaushlendra Pratap Singh Flowchart Basics

    Types of Computers :

    1) Analog Computers :- These computers perform the complex processing bydirectly measuring the continuous physical quantities.

    eg :- Slide Rule, a hand operated computer was developed in 1620-1630 for

    basic arithmetic calculations.

    Differential Analyzer used in gun directors & bomb sights is also an analog

    computer developed in 1876.Antikythera Mechanism was developed in the year 1901 in Greece for all

    Mathematical Operations.

    2) Digital Computers :- They represent the numerical quantities by discreteelectrical states ON & OFF i.e. 1 & 0. They can be referred to as Electronic

    Data Processing Machines.

    3) Hybrid Computers :- Computers with the features of Analog & Digitalcomputers are known as Hybrid Computers. They have the measuring

    capabilities of the analog computer & the logical, arithmetic & control

    capabilities of the digital computer.eg :- HRS 100 (Hybridni Racunarski Sistem) developed in 1971 by Mihaljo

    Pupin Institute Belgrade Serbia. It was used by Academic of Sciences inUSSR.

    Computers are classified in categories / shapes :

    1) Micro Computers (PC) 2) Mini Computers3) Mainframe Computers 4) Super Computers

    Parts of Information System :

    1) Hardware also simply known as computer. Any physical existence which canbe seen & touched.

    2) Software set of instructions or programs which tells the computer how to

    process the data.

    3) Data raw material or facts about anything which is used as input to get useful

    information / result.

    Desktop

    Portable

    Laptop / Notebook Palmtop / Handheld / PDA

    Micro Computer

  • 8/8/2019 Flowchart Basics

    6/17

    Kaushlendra Pratap Singh Flowchart Basics

    4) People the end-users who play a crucial role. Without people the computer isof no use.

    Hardware

    Processor Memory Input / Output Storage

    The procedure that transforms raw data into useful information is called

    processing. Processor is like the brain of the computer. The board to which theprocessor is connected is called as Motherboard or Mainboard. The termCentral Processing Unit ( CPU ) refers to the computers processing hardware.

    Control Unit controls the flow of instructions & data within the components.

    Arithmetic Logic Unit (ALU ) is responsible for performing all thecomputations like Arithmetic, Logical or Relational.

    Memory is computers electronic scratchpad. Programs are loaded into and run

    from memory. The most common type of memory is RAM ( Random AccessMemory ). The smallest measurement unit ofdata is 1 bit & that of memoryis 1 byte.

    1 byte : 8 bits

    1 kilo byte : 1024 bytes

    1 mega byte : 1024 kilo bytes

    1 giga byte : 1024 mega bytes

    1 tera byte : 1024 giga bytes

    Control Unit

    Memory ALU

    InputDevices

    OutputDevices

  • 8/8/2019 Flowchart Basics

    7/17

    Kaushlendra Pratap Singh Flowchart Basics

    1. ROM ( Read Only Memory ) is non volatile in nature. The permanentprograms like compilers, character shapes etc. are stores in the ROM. Soprograms once written cannot be erased.

    2. PROM ( Programmable Read Only Memory ) is also non volatile in

    nature, but the contents of PROM are decided by the user. Programs once writtencannot be erased or changed.

    3. EPROM ( Erasable Programmable Read Only Memory ) is volatile nature.

    Data can be erased or changed by exposing it to Ultraviolet rays of very highintensity, so that it may be ready to accept new contents.

    4. RAM ( Random Access Memory ) is volatile in nature. Information can be

    read from & written to RAM at any instance , but it loses the data when there isno electric supply.

    Input & output devices are those devices which are used to accept data &instruction from the user & return the processed data back to the user.

    eg :-

    Input Devices Output Devices

    Keyboard, Mouse, Scanner, Joysticks, Monitor, Printer, Speaker.

    Trackballs, Digital Camera, Microphones,Bar code readers, Electronic Pen,

    Touch screen & Modem has the functionality of both Input & Output.

    Storage device is to hold data. They come in two types :

    1) Primary / Volatile / Temporary : RAM

    2) Secondary / Non Volatile / Permanent : Harddisk, Floppy, CD, DVD,Tape Drives, RemovableHarddisks.

    Software brings machine to life. It is a set of instructions which tells thecomputer how to process the data. Software are of two types.

    Software

    System Software Application Software

    Tells the computer how to Tells the computer how touse its components. It is accomplish specific tasks for

    an interface between the user the user.

    & the PC. Eg. MS-Office etc.Eg : Operating System.

  • 8/8/2019 Flowchart Basics

    8/17

    Kaushlendra Pratap Singh Flowchart Basics

    System Software

    Operating System

    Single User Multi User

    Every machine having its own One operating systemoperating system operated by shared by many users on

    single user. different clients.

    Difference between DOS & WINDOWS

    DOS

    It is a command line operating system. Single tasking operating sytem.

    WINDOWS

    It is a Graphical User Interface (GUI). Multi-tasking operating system.

    Operations in ALU:

    Arithmetic Operators ( + , - , / , * , ** ) Relational Operators ( < , > , = , = , ) Logical Operators (AND , OR , NOT)

    (NOT) (AND)

    A NOT A

    FALSE TRUE

    TRUE FALSE

    A B A AND B

    FALSE FALSE FALSE

    FALSE TRUE FALSE

    TRUE FALSE FALSE

    TRUE TRUE TRUE

  • 8/8/2019 Flowchart Basics

    9/17

    Kaushlendra Pratap Singh Flowchart Basics

    (OR) (XOR)

    A B A OR B

    FALSE FALSE FALSE

    FALSE TRUE TRUE

    TRUE FALSE TRUE

    TRUE TRUE TRUE

    A B A XOR B

    FALSE FALSE FALSE

    FALSE TRUE TRUE

    TRUE FALSE TRUE

    TRUE TRUE FALSE

    (NAND) (NOR)

    A B A NAND B

    FALSE FALSE TRUEFALSE TRUE TRUE

    TRUE FALSE TRUE

    TRUE TRUE FALSE

    A B A NOR B

    FALSE FALSE TRUEFALSE TRUE FALSE

    TRUE FALSE FALSE

    TRUE TRUE FALSE

  • 8/8/2019 Flowchart Basics

    10/17

    Kaushlendra Pratap Singh Flowchart Basics

    Chapter 2 - Data Representation & Data Communication

    Introduction :

    Computer recognizes only two distinct physical states produced by electricity,

    magnetic polarity or reflected lights. All they can understand is the on & off

    i.e. ( 1 & 0 ) state which are reflected by switches called as transistors.

    1) Binary Numbering System uses the base as 2 . Base is also termed asRADIX.

    2) Decimal Numbering System uses the base as 10.

    Binary to Decimal Conversion

    101 = 1x22 + 0x21 + 1x20 101.011 = 1x22 + 0x21 + 1x20 + 0x2-1 +

    1x2-2 + 1x2-3

    = 4 + 0 + 1 = 4 + 0 + 1 + 0 + 0.25 + 0.125

    = 5 = 5.375

    ( 101 )2 = ( 5 )10 ( 101 .011 )2 = ( 5.375 )10

    Decimal to Binary Conversion

    2 132 6 1

    2 3 0

    2 1 1

    1 1

    0.125 x 2 = 0.250

    0.250 x 2 = 0.500

    0.500 x 2 = 1.000 ( 13.125 )10 = ( 1101.001 )2

    Ones Complement

    It can be obtained by flipping each digit. i.e. 1 to 0 & 0 to 1

    e.g. 11010 = 00101

    Twos Complement

    It can be obtained by adding 1 to its ones complement.

    e.g.Number : 11010

  • 8/8/2019 Flowchart Basics

    11/17

    Kaushlendra Pratap Singh Flowchart Basics

    Ones Compliment : 00101+ 1

    --------

    Twos Compliment 00110--------

    Data Communication & Networking :

    Electronic transfer of information between computers is called as DataCommunication.

    Computers communicate in two ways :

    1) Through Modems

    2) Through Networks

    Network is a way to connect computers together so that they can communicate,exchange information & share resources.

    Analog Communication

    Analog computers perform the complex processing by directly measuring thecontinuous physical systems.

    e.g. Telephone, Slide Rule used to measure length.

    Digital Communication

    Digital computers represent the numerical quantities by the discrete electric states

    ( ON | OFF ) which can be manipulated logically & arithmetically.

    Features of Networking

    1) Allows simultaneous access to critical programs & data.2) Allows people to share peripheral devices.3) Streamlining personal communication with email.4) Making the backup process easy.

    Types of Networks

    1) Local Area Network ( LAN ) :-

    A network of computers located relatively near each other & connected by cable is

    known Local Area Network. It permits all the computers connected to it to share

    hardware, software & data as if to be directly connected to the users computer. E.gComputers connected to each other within any organization or institute,

  • 8/8/2019 Flowchart Basics

    12/17

    Kaushlendra Pratap Singh Flowchart Basics

    2) Wide Area Network - (WAN):-

    When two or more networks are connected together generally across a wide

    geographical area using high-speed or dedicated telephone lines. WAN means

    network of networks. E.g. Internet.

    Protocols:-

    A protocol is a set of rules which dictates the format of a conversation between

    communicating stations.e.g. TCP / IP , FTP , HTTP

    Server

    Server 1 Server 2Gateway Gateway

    Gateway is a computer that connects

    to networks & translate the

    information.

  • 8/8/2019 Flowchart Basics

    13/17

    Kaushlendra Pratap Singh Flowchart Basics

    1) TCP / IP Tranmission Control Protocol / Internet Protocol:-

    On a network, data is sent in small groups called packets. A packet is a group of bits

    that includes header, payload & control elements that are transmitted together.

    2) FTP File Transfer Protocol:-

    FTP is required at the time of actual storing of files to & from the server. It can be

    also termed as uploading & downloading.

    3) HTTP HyperText Transfer Protocol:-

    HTTP is required to transfer the dynamic data from one page to another. Dynamic

    includes text, images, animations and dynamic text through forms like ( emailregistration ).

    Internet & Intranet:

    Internet means interconnection of networks. It is the product of a militaryundertaking. The Pentagons Advance Research Project Agency ( ARPA )funded its creation in 1969 as ARPANET.

    A LAN network or a software developed for internal messaging between employees

    within an organization is called Intranet.

    World Wide Web ( WWW )

    Designed by Tim Berners Lee. WWW exploits two technologies like Multimedia &

    Hypertext, together which is known as Hypermedia. Multimedia refers to combination

    of text, colour, graphics, sound, video in presentation of data. Hypertext means

    presentation of text in different format with embedded links or extra effects. Thelanguage used to create hypertext is called Hypertext Markup Language( HTML ).

    Uses of Internet

    1) Email & Chatting2) Online Shopping3) Online Reservation4) E-Learning5) Online Exams6) Online Banking etc.

    A B

    To : B

    From : A

    Content : Text

    Packet # : 1

    Hello

    To : B

    From : A

    Content : Text

    Packet # : 2

    How Are

    To : B

    From : A

    Content : Text

    Packet # : 3

    You ?

  • 8/8/2019 Flowchart Basics

    14/17

    Kaushlendra Pratap Singh Flowchart Basics

    Chapter 3 - Flowcharts Elementary Concepts

    Introduction

    Before solving a problem with the help of a computer, it is essential to plan the

    solution in a step by step manner. Such a planning is represented symbolically with

    the help of so called flowchart. Flowcharts are a modeling technique introduced in1940/50s and popularized for structured development as well as business modelingin 1970s (Gane and Sarson 1979).

    It is an important tool of systems analysts and programmers for tracing the

    information flow and logical sequence in data processing. Logic is essence of aflowchart.

    Flowcharts can be drawn for simple as well as complex operations and are possible

    even in a non-computerized environment. Trial and error should be avoided as thecomputer time is precious. The logic should be depicted in the flowchart.

    Computerization of data without a flowchart is like constructing a building without aproper design and detailed drawings.

    Types of Flowcharts

    Linear flow chart (or chain)

    Linear flow charts arrange items in one line,

    forming a "chain." Arrows indicate the order inwhich to read the text.

    Forked flow chart

    Forked flow charts include at least one fork

    that splits one sequence into two or more

    sequences. In this example the fork shows

    that more than one event is caused by therain.

  • 8/8/2019 Flowchart Basics

    15/17

    Kaushlendra Pratap Singh Flowchart Basics

    Cyclical flow chart (or loop)

    Cyclical flow charts (or loops) have all items arranged in an

    endless loop, showing that the sequence may be repeated.Any of its events can be seen as a starting point.

    Symbols used in Flowcharts

    A typical flowchart from older Computer Science textbooks may have the followingkinds of symbols:

    Start and end symbols, represented as ovals or rounded rectangles, usuallycontaining the word "Start" or "Stop", or another phrase signaling the start or

    end of a process, such as "submit enquiry" or "receive product".

    Arrows, showing what's called "flow of control" in computer science. An arrowcoming from one symbol and ending at another symbol represents that

    control passes to the symbol the arrow points to.

    Processing steps, represented as rectangles. Examples: "Add 1 to X"; "replaceidentified part"; "save changes" or similar.

    Input/Output, represented as a parallelogram. Examples: Get X from theuser; display X.

    Conditional (or decision), represented as a diamond (rhombus). Thesetypically contain a Yes/No question or True/False test. This symbol is uniquein that it has two arrows coming out of it, usually from the bottom point and

    right point, one corresponding to Yes or True, and one corresponding to No orFalse. The arrows should always be labeled. More than two arrows can be

    used, but this is normally a clear indicator that a complex decision is being

    taken.

    For a complex calculation or decision, a "pre-defined process" symbol can beused which is represented with two vertical lines inside the two sides of the

    rectangle.

    Connector or joining of two parts of program, represented as a circle

  • 8/8/2019 Flowchart Basics

    16/17

    Kaushlendra Pratap Singh Flowchart Basics

    Annotation basically to print the comments, represented as left squarebracket proceeding with doted line.

    Output can be in two ways a soft copy or hardcopy. For soft copy symbol is abullet shaped know as Visual Display & for hard copy it is a rectangle withwavy line know as Document Print Out.

    Advantages of using flowcharts

    The benefits of flowcharts are as follows:

    1. Communication: Flowcharts are better way of communicating the logic of asystem to all concerned.

    2. Effective analysis: With the help of flowchart, problem can be analysed inmore effective way.

    3. Proper documentation: Program flowcharts serve as a good programdocumentation, which is needed for various purposes.

    4. Efficient Coding: The flowcharts act as a guide or blueprint during thesystems analysis and program development phase.

    5. Proper Debugging: The flowchart helps in debugging process.6. Efficient Program Maintenance: The maintenance of operating program

    becomes easy with the help of flowchart. It helps the programmer to putefforts more efficiently on that part

    Limitations of using flowcharts

    1. Complex logic: Sometimes, the program logic is quite complicated. In thatcase, flowchart becomes complex and clumsy.

    2. Alterations and Modifications: If alterations are required the flowchartmay require re-drawing completely.

    3. Reproduction: As the flowchart symbols cannot be typed, reproduction offlowchart becomes a problem.

    4. The essentials of what is done can easily be lost in the technical details ofhow it is done.

    Constants and Variable

    Constants have values that do not change during the execution of the program. Itcan be declared using the term CONST.

    (e.g.) Constpi= 3.143

  • 8/8/2019 Flowchart Basics

    17/17

    Kaushlendra Pratap Singh Flowchart Basics

    A variable is any entity that can take on different values.Anything that can vary canbe considered a variable.

    ( e.g.) age can be considered a variable because age can take different values fordifferent people or for the same person at different times.

    In an attempt to solve problems on a computer, one has to express the steps for the

    solution in terms of simple conceptual instructions and operations and then obtainthe results.

    There may be number of ways to solve a given problem and the solution-methodsmay vary from person to person, depending on ones logic. But the basic steps wouldconstitute:

    i) Formulating the problem and deciding the input data, if any.ii) Identifying the various steps of computation that are must for the

    solution.iii) Identifying the points of decision i.e. under what circumstances a

    particular operation is to be performed and when it is not to beperformed.

    iv) Knowing the expected results and when to obtain the output.Besides these, a person has to decide the various type of variables that should beused to solve the problem.

    Assignments

    Draw flowcharts to get following outputs.

    1) Sum of first N positive integers.2) Find the least no out of 4 nos. given by user.3)