Slide 1 : Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi PROGRAMMING CONCEPTS – FORMALIZING LOGIC
Ruchi Sharma
ruchisharma1701@gmail.com
Slide 2 : General Concepts To solve a problem with the help of a computer, we need to write a program.
Programming needs the knowledge of
A programming language
A procedure (i.e. a set of steps)
These steps that are to be given to the computer so that it can solve the given problem, constitutes LOGIC. Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi
Slide 3 : Developing a Program – Steps Develop logic using the Algorithm & Flowchart
Write the program using a programming language
Key in the program using an editor
Debug
Test for the correctness of logic
Run the program
Enter valid input(s) & get the output(s) Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi
Slide 4 : Formalizing LOGIC - Algorithms Definition : a finite set of systematic steps that define a solution to a given problem.
An algorithm is a tool that lets the user pen down his/her logical thoughts about the solution in a natural language
These “logical thoughts”, when written in a programming language, builds up a program
An algorithm helps the programmer to think & reason about the problem & find a suitable solution
An algorithm is the basic idea or an outline of the program Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi
Slide 5 : Finiteness : an algorithm should be finite. It should terminate after a fixed number of steps
Definiteness : every step in the algorithm should be precisely defined. There should be no ambiguity
Effectiveness : each step in the algorithm should be basic. E.g. the operations mentioned should be valid & should take finite time
Input(s) : inputs, if any, should be defined properly
Output(s) : an algorithm should produce at least one result Algorithms - Features Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi
Slide 6 : Algorithms - Examples Example 1. An algorithm for adding two given numbers.
Step 1 : Start.
Step 2 : Input two numbers x & y.
Step 3 : Add x & y and store the sum in s.
Step 4 : Output s.
Step 5 : Stop. Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi
Slide 7 : Algorithms - Examples Example 2. An algorithm for finding the greater of two numbers.
Step 1 : Start.
Step 2 : Input two numbers x & y.
Step 3 : If x > y, output x.
Step 4 : If y > x, output y.
Step 5 : Stop. Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi
Slide 8 : Algorithms - Examples Example 3. An algorithm for finding the sum of first 10 natural numbers.
Step 1 : Start.
Step 2 : Let x1, s0.
Step 3 : If x > 10, go to step 7.
Step 4 : s s + x.
Step 5 : x x + 1.
Step 6 : Go to step 3.
Step 7 : Output s.
Step 8 : Stop. Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi
Slide 9 : Formalizing LOGIC - Flowcharts Definition : A flowchart is a pictorial/graphical representation of an algorithm.
In a flowchart
certain symbols are used for specific purposes
these symbols are connected among themselves to show the flow of information & processing (also called the flow of control) Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi
Slide 10 : Flowcharts - Symbols Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi start/stop action processing decision connector flow direction input/output
Slide 11 : Flowcharts – Examples Example 1 : Flowchart for adding two numbers Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi
Slide 12 : Flowcharts – Examples Example 2 : Flowchart for finding the greater of two numbers Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi
Slide 13 : Flowcharts – Examples Example 3 : Flowchart for finding the sum of first 10 natural numbers Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi
Slide 14 : Thank You Ruchi Sharma ruchisharma1701@gmail.com http://www.wiziq.com/tutor-profile/376074-Ruchi