Skip to main content

10 basic algorithms and their Flowcharts

Hello programmers,
Here are the 10 basic algorithms of programming which will help you to start to learn Algorithms and programming.

What are Algorithms??
Algorithms are the set of instructions or protocols which tells us what should be the next step of the process or program.

What are the Flowcharts??
Flowcharts are the diagramatic representation of steps involved in the code.
Flowcharts shows the path followed by data during the process or iteration.

Now following are the algorithms and their Flowcharts:

1) Algorithm for area of circle :
1.START
2.READ: The radius as "R" and area as "A"
3.INPUT: Get R and A from user
4.CAALCULATE: area
 4.1 A=3.14*R*R
5.PRINT: "The area of circle of circle"+A
6.STOP

Flowchart for area of circle:


2) Algorithm for factorial of 1 to 5 
numbers :
1.START
2.READ: The number as "N" and factorial
as "fact"
3.INPUT: Get "N" from user
4.Set the initial value of N and fact
5.CALCULATE the factorial

 5.1 fact=fact*N
 5.2 N=N+1
6.If 1=<N=<5
 then go to step 5
 Else
 Print("The factorial value of number is"+fact)
7.STOP
               
Flowcharts for factorial of 1 to 5 number:





3) Alogorithm for grade for student :
1.START
2.READ: Mark as "M"
3.INPUT: M from user
4.If 100>=M>=70
 then print ("The grade of student is
AA")
 Else go to step.5
5.If 70>M>=60
 then print ("The grade of student is BB" )
 Else go to step.6
6.If 60>M>=50
 then print ("The grade of student is
CC")
 Else go to step. 7
7.If 50>M>=40
 then print ("The grade of student is
DD")
 Else go to step.8
8. If 40>M>=0
 then print ("The grade of student is
FF")
 Else
 print(" error")
9.STOP

Flowchart for Grade of students:




4) Algorithm for largest number in three 
numbers :
1.START
2.READ: The numbers as x,y,z
3.Check if x>y
 3.1 If true , then check if x>z
 3.1.1 If true ,then print (" x is gretest
number")
 3.1.2 If false, then print ("z is gretest
number")
3.2 If false , then check y>z
 3.2.1 If true , then print ("y is gretest
number")
 3.2.2 If false, then print ("z is gretest
number")
4.STOP

Flowchart for largest number in three numbers :




5) Algorithm for the checking letter is consonent or vowel :

1.START
2.READ: letter as "cha"
3.INPUT: "cha" from user
4.If
cha=="a"||"A"||"e"||"E"||"i"||"I"||"o"||"O||"u
"
 ||"U"||
 then print ("The letter is vowel")
Else
 print("The letter is consonent")
5.STOP

Flowchart for checking letter is consonent or vowel:




6) Algorithm for simple interest
1.START
2.READ: Deposite,rate of interest , time period
as D,R,T and the simple interest as Z
3.INPUT: Get D,R,T from user
4.calculate : simple interest
 4.1 Z=D*R*T/100
5.PRINT: "The simple interest on deposite
is ",Z
6.STOP

Flowchart for Simple Interest:



7) Algorithm for sum of first 10 numbers:
1.START
2.READ: sum=0 and x=1
3.Check x<=10
4. If true
 then calculate sum
 4.1 sum=sum+x
 4.2 x=x+1
 Else
 print("The sum of first 10
numbers",sum)
5.STOP

Flowchart for sum of first 10 numbers :




8) Algorithm for swap value using third 
Variable:
1.START
2.READ: variables as a,b and third variable
as c
3.Swap the values
 3.1 c=a
 3.2 a=b
 3.3 b=c
4.PRINT:"a,b"
5.STOP

Flowchart for swapping the numbers:




9) Algorithm for first 10 odd and 10 even 
numbers:

1.START
2.READ: X=0 , Y=0 COUNT=1
3.If COUNT%2!=0
 then Y=Y+2
 Else X=X+2
4.COUNT = COUNT+1
 5.If COUNT>20
 then print (" The sum of first 10 odd numbers is
",Y)
 and print("the sum of first 10 even numbers
is",X)
6.STOP

Flowchart for odd and even numbers:





Some Notes :
1) The algorithms are important for making your products.
2) This are also used in day to day life
3) Flowcharts are drawn using  draw.io website



Thanks.



Comments

Popular posts from this blog

Engineering Mechanics | polar co-ordinates problem

Q. The collar A in Figure slides along the rotating rod OB. The angular position  of the rod is given by 𝜃 =2/3 *(𝜋𝑡)² rad and the distance of the collar from O varies as r =18t⁴+4 m, where time t is measured in seconds. Determine the velocity and acceleration vectors of the collar at t =0.4 s. Solution  :-     Given polar co-ordinates are      r = 18t⁴+4       and       𝜃 =2/3 ×(𝜋𝑡)²      r`= 72t³                        𝜃` =4/3 ×(𝜋𝑡)      r``= 216t²                    𝜃`` =4/3 ×(𝜋) At t=0.4 sec       r = 18(0.4)⁴+4 = 4.46m       r`= 72(0.4)³ = 4.608 m/a       r``= 216(0.4)² = 34.56 m/s²      𝜃 = 2×(3.14×0.4)²/3 =0.335 rad      𝜃`= 4×3.14×0.4/3   = 1.675 rad/sec      𝜃``= 4×3.14/3 = 4.188 rad/sec² The velocity vector is given by V = (r`) Er + (r×𝜃`) E𝜃     = 4.608 Er +4.46×1.675 E𝜃     = 4.608 Er + 7.47 E𝜃 Where Er - radial unit vector               E𝜃 -  angular unit vector Also acceleration vector is given by A = (r``- r𝜃`²)Er + (2r

Data Structures in C

  Data Structures A  data structure  is a particular way of organizing data in a computer so that it can be used effectively. Here are list of all data structures present in C language :- Array Linked list Stack Queue Binary Tree Binary Search Tree Heap Hashing Graph  Matrix Misc These are some basic data structures present in C. Don't stop learning read all these articles to know more.

Array Data Structure in C

Array Data Structure      An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array).      The above image can be looked as a top-level view of a staircase where you are at the base of the staircase. Each element can be uniquely identified by their index in the array (in a similar way as you could identify your friends by the step on which they were on in the above example). Array’s size :- In C language array has the fixed size meaning once size is given to it. It can’t change i.e. can’t shrink it, can’t expand it. The reason was that for expanding if we change the size we can’t be sure ( it’s not possible every time) that we get the next memory location to us as free. The shrinking will not work beca