Академический Документы
Профессиональный Документы
Культура Документы
1: INTRODUCTION:
C-language is a high-level programming language. Now what is the mean of
www.magix.in
www.magix.in
M1.3.1: ALGORITHMS:
An algorithm is the step-by-step solution to a certain problem. Algorithms can
be expressed in any language, from natural languages like English or French to
programming languages like FORTRAN.
We use algorithms every day. For example, a recipe for baking a cake is an
algorithm. In another example a plan of how you will play a game is simple
algorithm.
Page 3
www.magix.in
:
:
:
:
:
:
:
Begin
Read the values A and B
Store the values of A into temp //here temp is a variable
Store the value of B into A
Store the value of temp into B
Print the values of A and B
END.
Another Example:
Write an algorithm to calculate the sum of n numbers.
Algorithm SumOfNumbers:
This algorithm will calculate the sum of n numbers.
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Step 9
:
:
:
:
:
:
:
:
:
Begin
Read the value of total numbers to be summed into n
Set sum=0
Repeat step 5 to step 7 while n>0
Read a value of x
Add the value of x with the value of sum and store the result in sum
M1.3.2: FLOWCHARTS:
A flowchart is a pictorial representation of an algorithm,
indicating the flow of the data and the operations performed on
data. It provides the visual representation of an algorithm by
representing each and every step of an algorithm with the help of
different symbols. There are many symbols for representing
flowcharts. But at this stage, we will discuss only basic symbols of
drawing a flowchart, which are as follows:
Page 4
www.magix.in
Page 5
www.magix.in
Page 6
www.magix.in