FYBCS C -Programming Assignment 1
Problem Solving using Pseudo code and Flowchart, Simple programs, Understanding errors and error handling.
Pseudocode :-
Definition: Pseudocode is an informal way of programming description that does not require any strict programming language syntax or underlying technology considerations. It is used for creating an outline or a rough draft of a program. Pseudocode summarizes a program’s flow, but excludes underlying details. System designers write pseudocode to ensure that programmers understand a software project's requirements and align code accordingly.
Advantages of pseudocode –
• Pseudocode is understood by the programmers of all types.
• it enables the programmer to concentrate only on the algorithm part of the code development.
• It cannot be compiled into an executable program. Example, Java code : if (i < 10) { i++; } pseudocode :if i is less than 10, increment i by 1.
1.. If student's grade is greater than or equal to 60
- Print "passed"
- Print "failed"
- 2. Set total to zero
Set grade counter to one
While grade counter is less than or equal to ten
- Input the next grade
- Add the grade into the total
Set the class average to the total divided by ten
Print the class average.
Algorithm :-
Algorithm is a step-by-step procedure,
which defines a set of instructions to be executed in a certain order to get
the desired output. Algorithms are generally created independent of underlying
languages, i.e. an algorithm can be implemented in more than one programming
language.
It must have the following characteristics:
Clear and Unambiguous: Algorithm should be clear and unambiguous. Each of its steps should be clear in all aspects and must lead to only one meaning.
Well-Defined Inputs: If an algorithm says
to take inputs, it should be well-defined inputs.
Well-Defined Outputs: The algorithm must
clearly define what output will be yielded and it should be well-defined as
well.
Finite-ness: The algorithm must be finite,
i.e. it should not end up in an infinite loops or similar.
Feasible: The algorithm must be simple,
generic and practical, such that it can be executed upon will the available
resources. It must not contain some future technology, or anything.
Language Independent: The Algorithm
designed must be language-independent, i.e. it must be just plain instructions
that can be implemented in any language, and yet the output will be same, as
expected.
How to Design an Algorithm?
In order to write an algorithm, following
things are needed as a pre-requisite:
The constraints of the problem that must be
considered while solving the problem.
The input to be taken to solve the problem.
The output to be expected when the problem
the is solved.
The solution to this problem, in the given
constraints.
Examples:-
Problem Definition: Write an algorithm to add given two numbers.
Problem Definition: Write an algorithm for Subtracting two Numbers.
These are some points to keep in mind while developing a flowchart −
Advantages of flowchart:
• Flowchart is an excellent way of
communicating the logic of a program.
• Easy and efficient to analyze problem
using flowchart.
• During program development cycle, the flowchart plays the role of a blueprint, which makes program development process easier.
• After successful development of a program, it needs continuous timely maintenance during the course of its operation. The flowchart makes program or system maintenance easier.
• It is easy to convert the flowchart into
any programming language code.
No comments:
Post a Comment