Find Area of a Circle
We need formula A= 3.14 * R * R
So Now we Will Put it in Algorithm
First we need a value of R so we will take it from user
Algorithm Starts :
1. Area <-- 1
2. Input R
3. Area <---3.14*R*R
4. Print Area
5. End
Find The Minimum from given two numbers
Logic : Scan two numbers from user,Compare them,Print the Minimum.
1. Input N1
2. Input N2
3. If N1>N2 Go to (6)
4. Print N1
5. Go to (7)
6. Print N2
7. End
Find The Minimum from given three numbers
Logic Compare two set of number one by one
1. Input N1
2. Input N2
3. Input N3
4. If N1>N2 Go to (8)
5. If N1>N3 Go to (11)
6. Print N1
7. Go to (12)
8. If N2>N3 Go to (11)
9. Print N2
10. Go to (12)
11. Print N3
12. End
Find Sum of First 100 odd numbers
Logic: Use a sum variable, use a counter , use another variable to give step value of two
1. count<--1
2. sum<--0
3. step <-- 1
4. sum<--sum+step
5.step<-- step + 2
6. count<--count+1
7. If count<=100 Go to (4)
8. Print Sum
9. End
Generate First N Fibonacci
Logic: Fibonacci :Total of No and its previous no
2+3=5
3+5=8
5+8=13
This is the formula of Fibonacci
1. Input N
2. Count<--2
3. F1<--0
4. F2<--1
5. Print F1
6. Print F2
7. F3<--F1+F2
8. Print F3
9.Count<--Count+1
10. F1<-- F2
11. F2 <-- F3
12. If Count< N Go to (7)
13. End
Addition of First 15 Numbers Divisable by 7
Logic: Use of MOD function to know whether the number is divisible by 7 or not
1. Count<--0
2. Sum <-- 0
3. Num <-- 1
4. Num<--Num+1
5. If (Num%7==0) Go to (7)
6. Go to (4)
7. Sum<--Sum+Num
8. Count<--Count+1
9. If Count < 13 then Go to (4)
10. Print Sum
11. End
Calculate Total Salary as Per Rules Given
Basic<=1500_________HRA 400
Basic>1500 & <6000___________HRA 1500
Basic >6000__________HRA 2000
DA
15 % _______ if Basic <= 2500 else 10 %
MA Rs. 200
Salary Formula: Basic +HRA +DA +MA
1. Input Basic
2. Salary<--0
3. HRA<--0
4. DA<--0
5. If Basic <=1500 Go to (9)
6. If Basic <6000 Go to (11)
7. HRA<--2000
8. Go to (12)
9. HRA<--400
10. Go to (12)
11. HRA<--1500
12. If Basic<=2500 Go to (15)
13. DA<--0.10*Basic
14. Go to (16)
15. DA<--0.15*Basic
16. Salary<--Basic+HRA+DA+200
17. Print Salary
18. End
Count Electricity Bill
Same as above but here Electricity bill
First 50 units 50p/unit
Next 50 0.75/u
Next 100 1.25/u
above 200 1.75/u
Fuel charge 40% of unit charge
Government tax 15% of unit and fuel charge
Meter rent 20 Rs.
1. Input Units
2. If Units <= 50 Go to (7)
3. If Units <=100 Go to (9)
4. If Units <= 200 Go to (11)
5. Unit_Charge<--50*0.50+50*0.75+100*1.25+(
6. Go to (12)
7. Unit_Charge<--Units*0.50
8. Go to (12)
9. Unit_Charge<--50*0.50+(Units-50)*0.75
10. Go to (12)
11. Unit_Charge<--50*0.50+50*0.75+(Units-100
12. Fuel_Charge<--0.40*Unit_Charge
13. Govern_Tax<--0.15*(Fuel_Charge+Unit_Char
14. Bill<--Unit_Charge+Fuel_Charge+Govern_Ta
15. Print Bill
16. End
Read all C Programming tutorials Click here

0 comments