Unit 1 Prog Logic Development
Unit 1 Prog Logic Development
Unit 1 Prog Logic Development
Hr : 4 Marks : 8
1.1 Fundamentals of Algorithms
1.2 Algorithmic Problems
1.3 Flowcharts
Program :
A program is a set of instructions that a computer follows in order to perform a particular
task.
Problem-solving techniques
(Explain problem-solving techniques in detail. (List 1 Mark, explanation 3 Marks))
1. Algorithm
2. Flowchart
3. Pseudo-code
Or
Algorithm: - Algorithm is a stepwise set of instructions written to perform a specific task.
Flowchart: - Flowchart is a diagrammatic representation of steps/procedure to perform a
specific task.
Explain the following terms: Algorithm (ii) Flowchart 4 mks --Summer 17 w 17
Ans :
(i) algorithm: It is a step by step procedure to solve a problem. Starting from the initial step and
input it proceeds in a sequential step by step way to get the output.
Eg: The algorithm to add two numbers can be written in the following way:
1. start
2. declare 3 variables a,b,c;
3. get the input values for the variables a and b
4. calculate the sum c = a+b
5. display the output c
6. Stop
(ii) Flowchart: It is the diagrammatic representation of methodically solving a problem.
It can also be called as the diagrammatic representation of an algorithm.
The different symbols used in flowcharts are:
* Explain the term flowchart and algorithm with an example. (w 17 mks 4)
Ans :
Flowchart: A flowchart is a diagrammatical representation of solution for the given task.
Write an algorithm and draw a flowchart to add two numbers. (S 18 --- 4 marks)
Algorithm:
step 1: Start
step 2: Input values for variables no1 and no2.
step 3: Calculate addition of two values using formula as
sum = no1 + no2.
step 4: Display addition
step 5: Stop
Define algorithm and flowchart. (W 18 ----2 mks)
Algorithm: - Algorithm is a stepwise set of instructions written to perform a specific task.
Flowchart: - Flowchart is a diagrammatic representation of steps/procedure to perform a
specific task.
Write algorithm and draw flowchart to print whether entered number is even or odd.
(w18- 4 mks)
Algorithm :
1. Start
2. Input a number.
3. Divide the number by 2 to find remainder.
4. If remainder of the division is 0, display the number is even
otherwise display the number as odd
5. Stop.
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a > b
If a > c
Display a is the largest number.
Else
Display c is the largest number.
Else
If b > c
Display b is the largest number.
Else
Display c is the greatest number.
Step 5: Stop
Algorithm : Check whether a number is prime or not
Step 1: Start
Step 2: Declare variables n, i, flag.
Step 3: Initialize variables
flag ← 1
i←2
Step 4: Read n from the user.
Step 5: Repeat the steps until i=(n/2)
5.1 If remainder of n÷i equals 0
flag ← 0
Go to step 6
5.2 i ← i+1
Step 6: If flag = 0
Display n is not prime
else
Display n is prime
Step 7: Stop
State the importance of flowcharts with the symbols used for drawing flowchart.
(Importance – 2 Marks, Symbols – 2 Marks)} W 2019
Ans : Importance : For 2 marks
Sometimes it's more effective to visualize something graphically that it is to describe it
with words.
Flowchart is the tool which helps to represent logic of the program pictorially.
Flowcharts explain a process clearly through symbols and text.
For 4 Marks W 2019
Importance :
A flowchart is a type of diagram that represents an algorithm.
It is a visual representation of a sequence of steps to complete the process.
A flow chart describes a process using symbols rather than words.
Computer programmers use flow charts to show where data enters the program, what processes
the data goes through, and how the data is converted to output.
-can be used to quickly communicate the ideas or plans that one programmer envisions to other
people who will be involved in the process.
- aid in the analysis of the process to make sure nothing is left out and that all possible inputs,
processes, and outputs have been accounted for.
-help programmers develop the most efficient coding because they can clearly see where the data
is going to end up.
- help programmers figure out where a potential problem area is and helps them with debugging
or cleaning up code that is not working.
- are a useful tool in visualizing a module's flow of execution before writing any code. This allows
developers to do three things: verify the algorithm's correctness before writing code,
visualize how the code will ultimately be written, and communicate and document the
algorithm with other developers and even non-developers.
-may be used in conjunction with other tools, such as pseudo-code, or may be used by itself to
communicate a module's ultimate design, depending on the level of detail of the flowchart.
Assignment 1
Draw flow chart for addition of two numbers. 2 Marks W 2019
Draw flowchart for checking whether given number is even or odd. 2 Marks S 2019
Write an algorithm to determine the given number is odd or even. 4Marks W 2019 ,S 2019
Draw flowchart for checking weather given number is prime or not 4 Marks S 2019
Draw flowchart for finding largest number among three numbers. 4 Marks S 2019