Examples of Algorithms and Flowcharts (With C Code) : Finding Area of The Square
Examples of Algorithms and Flowcharts (With C Code) : Finding Area of The Square
1. Start Start
2. Read a, b
3. c=a+b
4. Print or display c Read a, b
5. Stop
c=a+b
Write c
Stop
Start
1. Start
2. Read length, L
3. area = L*L Read L
4. Print or display area
5. Stop
area = L*L
Write
area
Stop
Start
1. Start
2. Read side length, a Read a
3. Read side length b
4. area = a*b
5. Print or display area
Read b
6. Stop
area = a*b
Write
area
Stop
Start
1. Start
2. Read a, b, c
3. s = (a+b+c)/2
Read a, b, c
4. A=sqrt (s *(s-a)*(s-b)*(s-c))
5. Print or display A
6. Stop
s = (a+b+c)/2
A = sqrt s(s-a)*(s-b)*(s-c)
Write
A
Stop
1. Start Start
2. Read length L
3. Area A = L*L
4. Perimeter P = 4*L Read L
5. Print or display A,P
6. Stop
A = L*L
P = 4*L
Write
A, P
Stop
1. Start
2. Read 3 numbers A, B, C
3. Calculate the average by
the equation:
Average = (A + B + C)/3
4. Print average
5. Stop
1. Start
2. Read A,B
3. If A > B then
Print A is large
else
Print B is large
4. Stop
1. Start
2. Read two values into two variables a, b
3. Declare third variable, c
c=a
a=b
b=c
4. Print or display a, b
5. Stop
Start
1. Start
2. Read P, N, R
3. SI=(PNR)/100 Read P, N, R
4. Print SI
5. Stop
SI = (P*N*R)/100
Write
SI
Stop
1. Start
2. Initialize F = 0, C = 0
3. Read F
4. C = (F-32) * 5/9
5. Write C
6. Stop
Start
1. Start
2. Read N
3. Initialize F =1, i = 1
Read N
4. F = F * i;
5. Increment i by 1
6. Repeat step 4 & 5 until i = N
F=1
7. Print F i=1
8. Stop
F=F*i
i=i+1 No Is
i = N?
Yes
Write F
Stop
1. Start
2. Initialize count = 0, sum = 0
3. count = count + 1
4. sum = sum + count
5. Repeat steps 3,4 until count > 5
6. Print sum
7. Stop
1. Start
2. Initialize count i = 1, sum = 0 Start
3. sum = sum + i
4. Increment i by 1
i=1
5. Repeat steps 3 & 4 until i > 100 sum = 0
6. Print sum
7. Stop
sum = sum + i
i=i+1
No Is
i>100?
Yes
Write
sum
Stop
1. Start
2. Read n
3. count=0
4. sum=0
5. count = count + 1
6. sum = sum + count
7. Repeat steps 5 & 6 until
count > n
8. Print sum
9. Stop
Start
1. Start
2. Read n
3. i = 0, sum = 0
Read n
4. i=i+1
5. sum = sum + (i*i)
6. Repeat steps 4 and 5 until i > n
i=0
7. Print sum sum = 0
8. Stop
i=i+1
sum = sum + (i*i)
No Is
i>n
Yes
Write
sum
Stop
10 | P a g e Y o u t u b e . c o m / E n g i n e e r s T u t o r www.EngineersTutor.com
16. To find the sum of all even numbers up to ‘n’
Start
1. Start
2. Read n
3. count=0 READ n
4. sum=0
5. count = count + 2
6. sum = sum + count count = 0
7. Repeat steps 5 & 6 until count ≤ n sum = 0
8. Print sum
9. Stop
count = count+ 2
No Is
count ≤ n
Yes
Write
sum
Stop
11 | P a g e Y o u t u b e . c o m / E n g i n e e r s T u t o r www.EngineersTutor.com
17. To find Product of numbers up to N
1. Start Start
2. Read n
3. count i = 1
4. product = 1 READ n
5. product=count*product
6. count = count + 1
7. Repeat steps 5,6 until count ≤ N count i = 1
8. Print product product = 1
9. Stop
count = count + 1
product = product*count
Is
count ≤ n
No
Yes
Write
product
Stop
12 | P a g e Y o u t u b e . c o m / E n g i n e e r s T u t o r www.EngineersTutor.com
18. Sum of first 50 odd numbers
Algorithm Flowchart Program
1. Start
2. sum=0, n = 1
3. sum=sum + n
4. n=n+2
5. Repeat steps 4 and 5 until
n ≤ 99
6. Print sum
7. Stop
13 | P a g e Y o u t u b e . c o m / E n g i n e e r s T u t o r www.EngineersTutor.com