Introduction ofAlgorithms and Flowchart
What is an algorithm? Named after Persian mathematician Mohammad Al- Khwarizmi A sequential solution of any problem Written in human understandable form Requires a clear understanding of the problem
What is an algorithm? An algorithm describes the step by step action to solve a problem..
What is an algorithm? An algorithm is a self-contained step-by- step set of operations to be performed to solve a specific problem or a class of problems. A computer program is a sequence of instructions that comply the rules of a specific programming language , written to perform a specified task with a computer.
Example of an algorithm 1. For example, an algorithm for driving to a friend's house could be:
Example of an algorithm Solution # 1 1. Find your keys 2. Walk out of the house 3. Close the door 4. Open the car door 5. Get into the car 6. Put the key into the ignition 7. Start the car
Example of an algorithm 2. Write an algorithm to change a numeric grade to a pass/fail grade. 15
Example of an algorithm Solution # 2 Pass/Fail Grade Input: One number if (the number is greater than or equal to 50) then 1.1 Set the grade to “pass” else 1.2 Set the grade to “fail” End if Print the grade End
Example of an algorithm 15 3. Write an algorithm for grading system by following method. Marks range Grade >=80 A >=70 & <80 B >=60 & <70 C >=50 & <60 D <50 F
Example of an algorithm Solution # 3 Input: One number 1. if (the number is between 80 and 100, inclusive) then 1. Set the grade to “A” End if 2. if (the number is between 70 and 79, inclusive) then 1. Set the grade to “B” End if
3. if (the number is between 60 and 69, inclusive) then 1. Set the grade to “C” End End if 4. if (the number is between 50 and 59, inclusive) then 1. Set the grade to “D” End End if 5. If (the number is less than 50) then 1. Set the grade to “F” End End if 6. Print the grade End
Flowchart A graphical representation of an algorithm, often used in the design phase of programming to work out the logical flow of a program. Visual way to represent the information flow Make our logic more clear Help during writing of program Make testing and debugging easy
Basic Flowcharting Symbols
Basic Flowcharting Symbols SYMBOL ACTIVITY ON PAGE CONNECTOR OFF PAGE CONNECTOR
Flowchart or program constructs  Sequence: The order of execution, this typically refers to the order in which the code will execute. Normally code executes line by line, so line 1 then 2 then 3 and so on.  Selection: Selection, like branching, is a method of controlling the execution sequence, you can create large control blocks, using if statements testing a
Flowchart or program constructs  condition, or switch statements evaluating a variable etc to control and change the execution of the program depending on this environment and changing variables.  Iteration (Repetition): Iteration is typically used to refer to collections and arrays of variables and data. Repeating set of instruction. Counting from 1 to 10, you are
Flowchart or program constructs  iterating over the first 10 numbers. for, while, do-while loops will be implemented for iteration.
Flowchart or program constructs
Flowchart or program constructs
Flowchart or program constructs
Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. Algorithm Step 1: Start Step 2: Take Width and Length as input Step 3: Calculate Area by Width* Length Step 4: Print Area. Step 5: End
Step 1: Step 2: Step 3: Step 4: Step 5: Start Input W, L A = L x W Print A End Input W, L A = Lx W END Print A START
Write an algorithm and draw a flowchart that will take marks of four subjects and calculate the average. Then if average marks are greater than 50 then print PASS otherwise print FAIL.
Step 1: Start Step 2: Input M1,M2,M3,M4 Step 3: AVG = (M1+M2+M3+M4)/4 Step 4: if (AVG <50) then Print “FAIL” else Print “PASS” endif Step 5: End START Input M1,M2,M3,M4 AVG(M1+M2+M3+M4)/4 IS AVG<50 END Y N Print “PASS” Print “FAIL”
Write an algorithm and draw a flowchart to convert the length in feet to centimeter.
Algorithm Step 1: Step 2: Start Input ft Step 3: cm = ft * 30 Step 4: Print cm Step 5: End Input ft cm = ft x 30 END Flowchart Print cm START
THANK YOU!!!

ALGORITHM PPT GUIDE.pdf

  • 1.
  • 2.
    What is analgorithm? Named after Persian mathematician Mohammad Al- Khwarizmi A sequential solution of any problem Written in human understandable form Requires a clear understanding of the problem
  • 3.
    What is analgorithm? An algorithm describes the step by step action to solve a problem..
  • 4.
    What is analgorithm? An algorithm is a self-contained step-by- step set of operations to be performed to solve a specific problem or a class of problems. A computer program is a sequence of instructions that comply the rules of a specific programming language , written to perform a specified task with a computer.
  • 5.
    Example of analgorithm 1. For example, an algorithm for driving to a friend's house could be:
  • 6.
    Example of analgorithm Solution # 1 1. Find your keys 2. Walk out of the house 3. Close the door 4. Open the car door 5. Get into the car 6. Put the key into the ignition 7. Start the car
  • 7.
    Example of analgorithm 2. Write an algorithm to change a numeric grade to a pass/fail grade. 15
  • 8.
    Example of analgorithm Solution # 2 Pass/Fail Grade Input: One number if (the number is greater than or equal to 50) then 1.1 Set the grade to “pass” else 1.2 Set the grade to “fail” End if Print the grade End
  • 9.
    Example of analgorithm 15 3. Write an algorithm for grading system by following method. Marks range Grade >=80 A >=70 & <80 B >=60 & <70 C >=50 & <60 D <50 F
  • 10.
    Example of analgorithm Solution # 3 Input: One number 1. if (the number is between 80 and 100, inclusive) then 1. Set the grade to “A” End if 2. if (the number is between 70 and 79, inclusive) then 1. Set the grade to “B” End if
  • 11.
    3. if (thenumber is between 60 and 69, inclusive) then 1. Set the grade to “C” End End if 4. if (the number is between 50 and 59, inclusive) then 1. Set the grade to “D” End End if 5. If (the number is less than 50) then 1. Set the grade to “F” End End if 6. Print the grade End
  • 12.
    Flowchart A graphical representationof an algorithm, often used in the design phase of programming to work out the logical flow of a program. Visual way to represent the information flow Make our logic more clear Help during writing of program Make testing and debugging easy
  • 13.
  • 14.
    Basic Flowcharting Symbols SYMBOLACTIVITY ON PAGE CONNECTOR OFF PAGE CONNECTOR
  • 15.
    Flowchart or programconstructs  Sequence: The order of execution, this typically refers to the order in which the code will execute. Normally code executes line by line, so line 1 then 2 then 3 and so on.  Selection: Selection, like branching, is a method of controlling the execution sequence, you can create large control blocks, using if statements testing a
  • 16.
    Flowchart or programconstructs  condition, or switch statements evaluating a variable etc to control and change the execution of the program depending on this environment and changing variables.  Iteration (Repetition): Iteration is typically used to refer to collections and arrays of variables and data. Repeating set of instruction. Counting from 1 to 10, you are
  • 17.
    Flowchart or programconstructs  iterating over the first 10 numbers. for, while, do-while loops will be implemented for iteration.
  • 18.
  • 19.
  • 20.
  • 21.
    Write an algorithmand draw a flowchart that will read the two sides of a rectangle and calculate its area. Algorithm Step 1: Start Step 2: Take Width and Length as input Step 3: Calculate Area by Width* Length Step 4: Print Area. Step 5: End
  • 22.
    Step 1: Step 2: Step3: Step 4: Step 5: Start Input W, L A = L x W Print A End Input W, L A = Lx W END Print A START
  • 23.
    Write an algorithmand draw a flowchart that will take marks of four subjects and calculate the average. Then if average marks are greater than 50 then print PASS otherwise print FAIL.
  • 24.
    Step 1: Start Step2: Input M1,M2,M3,M4 Step 3: AVG = (M1+M2+M3+M4)/4 Step 4: if (AVG <50) then Print “FAIL” else Print “PASS” endif Step 5: End START Input M1,M2,M3,M4 AVG(M1+M2+M3+M4)/4 IS AVG<50 END Y N Print “PASS” Print “FAIL”
  • 25.
    Write an algorithmand draw a flowchart to convert the length in feet to centimeter.
  • 26.
    Algorithm Step 1: Step 2: Start Inputft Step 3: cm = ft * 30 Step 4: Print cm Step 5: End Input ft cm = ft x 30 END Flowchart Print cm START
  • 27.