0% found this document useful (0 votes)
9 views9 pages

C Unit Ii

The document provides an overview of flowcharts, algorithms, and programming processes, highlighting their definitions, advantages, and disadvantages. It details the steps involved in problem analysis, algorithm development, program coding, compilation, execution, debugging, and documentation. Additionally, it outlines the qualities of a good algorithm and its characteristics, emphasizing the importance of clear and precise instructions.

Uploaded by

Aditya Deshmukh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views9 pages

C Unit Ii

The document provides an overview of flowcharts, algorithms, and programming processes, highlighting their definitions, advantages, and disadvantages. It details the steps involved in problem analysis, algorithm development, program coding, compilation, execution, debugging, and documentation. Additionally, it outlines the qualities of a good algorithm and its characteristics, emphasizing the importance of clear and precise instructions.

Uploaded by

Aditya Deshmukh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UNIT II

1
Flowchart
A flowchart is a type of diagram that represents a workflow or process. A
flowchart can also be defined as a diagrammatic representation of an algorithm, a
step-by-step approach to solving a task.
The flowchart shows the steps as boxes of various kinds, and their order by
connecting the boxes with arrows. This diagrammatic representation illustrates a
solution model to a given problem. Flowcharts are used in analyzing, designing,
documenting or managing a process or program in various fields.
ANSI/ISO
Name Description
Shape
Shows the process's order of operation. A line
Flow line coming from one symbol and pointing at another.
(Arrowhead) Arrowheads are added if the flow is not the
Standard top-to-bottom, left-to right.
Indicates the beginning and ending of a program or
sub-process. They usually contain the word "Start"
Terminal or "End", or another phrase signaling the start or
end of a process, such as "submit inquiry" or "receive product".
Represents a set of operations that changes value,
form, or location of data. Represented as a
Process rectangle.
Shows a conditional operation that determines
which one of the two paths the program will take.
The operation is commonly a yes/no question or
true/false test. Represented as a diamond
Decision
(rhombus).
Indicates the process of inputting and outputting
data, as in entering data or displaying results.
Input/output
Represented as a parallelogram.
Pairs of labeled connectors replace long or
On-page
confusing lines on a flowchart page. Represented by
Connector
a small circle with a letter inside.

2
Flow Chart Add Two number

Flow Chart compare two number

3
Advantages of using Flowcharts
 Communication: - Flowcharts are a better way of communicating the logic
of a system to all concerned.
 Effective analysis:- With the help of flowcharts, problems can be analyzed
more effectively.
 Proper documentation:-Program flowcharts serve as a good program
documentation needed for various purposes.
 Efficient coding:- Flowcharts act as a guide or blueprints during the
systems analysis and program development phase.
 Proper debugging:- Flowcharts help in the debugging process.
 Efficient program maintenance:- The maintenance of an operating
program becomes easy with the help of a flowchart.

Disadvantages of using flowcharts

 Complex logic: - Sometimes , the program logic is quite complicated . In


such a case a flowcharts become complex.
 Alterations and modification: - If alterations are required the flowcharts
may need to be redrawn completely.
 Reproduction: - Since the flowcharts symbols cannot be typed in, the
reproduction of flowcharts become a problem.
 The essentials of what has to be done can easily be lost in the technical
details of how it is to be done.

4
Problem Analysis

1. Problem Analysis: Identify the issues. Be clear about what the


problem is. ...

Understand everyone's interests. ...

List the possible solutions (options) ...

Evaluate the options.

Select an option or options. ...

Document the agreement(s). ...

Agree on contingencies, monitoring, and evaluation.

5
2. Algorithm Development

An algorithm in general is a sequence of steps to solve a particular


problem. Algorithms are universal. The algorithm you use in C
programming language is also the same algorithm you use in every
other language. An algorithm produces the same output information
given the same input information, and several short algorithms can be
combined to perform complex tasks such as writing a computer
program.

3. Flow Chart

A flowchart is a formalized graphic representation of a logic


sequence, work or manufacturing process, organization chart, or
similar formalized structure. The purpose of a flow chart is to provide
people with a common language or reference point when dealing
with a project or process. Flowcharts use simple geometric symbols
and arrows to define relationships.

4. Program Coding

A Programming (or coding) language is a set of syntax rules that


define how code should be written and formatted. Thousands of
different programming languages make it possible for us to create
computer software, apps and websites.

5. Compile and Execution

Compilation

First, the source ‘.java’ file is passed through the compiler, which then
encodes the source code into a machine independent encoding, known
as Bytecode. The content of each class contained in the source file is
stored in a separate ‘.class’ file. While converting the source code into
the bytecode.

Execution

The class files generated by the compiler are independent of the


machine or the OS, which allows them to be run on any system. To run,
the main class file (the class that contains the method main) is passed to
12
6
the JVM, and then goes through three main stages before the final
machine code is executed.

6. Debugging and testing

Testing means verifying correct behavior. Testing can be done at all


stages of module development: requirements analysis, interface
design, algorithm design, implementation, and integration with other
modules. In the following, attention will be directed at
implementation testing. Implementation testing is not restricted to
execution testing. An implementation can also be tested using
correctness proofs, code tracing, and peer reviews, as described
below.
Debugging is a cyclic activity involving execution testing and code
correction. The testing that is done during debugging has a different
aim than final module testing. Final module testing aims to
demonstrate correctness, whereas testing during debugging is
primarily aimed at locating errors. This difference has a significant
effect on the choice of testing strategies.

7. Documentation
The documentation section contains a set of comment including the
name of the program other necessary details. Comments are ignored
by compiler and are used to provide documentation to people who
reads that code.

Algorithm in Programming

In programming, algorithm is a set of well defined instructions in sequence to


solve the problem. An algorithm is defined as a step-by-step procedure or method
for solving a problem by a computer in a finite number of steps. Steps of an
algorithm definition may include branching or repetition depending upon what
problem the algorithm is being developed for. While defining an algorithm steps
are written in human understandable language and independent of any
programming language. We can implement it in any programming language of our
choice.

7
Qualities of a good algorithm

1. Input and output should be defined precisely.


2. Each steps in algorithm should be clear and unambiguous.
3. Algorithm should be most effective among many different ways to solve a
problem.
4. An algorithm shouldn't have computer code. Instead, the algorithm should
be written in such a way that, it can be used in similar programming
languages.

Write an algorithm to add two numbers entered by user.

Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step 5: Display sum
Step 6: Stop

Write an algorithm to find the largest among three different numbers


entered by user.

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

8
Advantages of Algorithms:

1. It is a step-wise representation of a solution to a given problem, which


makes it easy to understand.
2. An algorithm uses a definite procedure.
3. It is not dependent on any programming language, so it is easy to understand
for anyone even without programming knowledge.
4. Every step in an algorithm has its own logical sequence so it is easy to
debug.
5. By using algorithm, the problem is broken down into smaller pieces or steps
hence, it is easier for programmer to convert it into an actual program.

Disadvantages of Algorithms:

1. Algorithms is Time consuming.


2. Difficult to show Branching and Looping in Algorithms.
3. Big tasks are difficult to put in Algorithms.

Characteristics of Algorithms:

1. Precision – the steps are precisely stated(defined).


2. Uniqueness – results of each step are uniquely defined and only depend on
the input and the result of the preceding steps.
3. Finiteness – the algorithm stops after a finite number of instructions are
executed.
4. Input – the algorithm receives input.
5. Output – the algorithm produces output.
6. Generality – the algorithm applies to a set of inputs.

You might also like