An algorithm is a step by step way to solve a perticular problem in limited amount of time. For more details. Cick here...
Example 1. Write an algorithm To add two numbers.
Sol. Step 0. Start
Step 1. Input two numbers a, b.
Step 2. Declare one more variable for result c.
Step 3. Perform addition, c=a+b.
Step 4. Display output, c
Step 5. End
Example 2. Write an algorithm to display area of circle and square.
Sol. Step 0. Start
Step 1. Input Circumference as C for circle.
Step 2. Input Side as S for square.
Step 4. Declare two variable for are of circle and
square ac, as respectively.
Step 5. Calculate area, ac=3.14*C*C
Step 6. Calculate area, as=S*S
Step 7. Display output, ac, as.
Step 8. End
Example 3. Write an alsorithm to find net salary and tax to be paid if
input is basic salary. Hra is 10%, Da is 15%. Net salary= basic salary+hra+da. Tax will be paid if net salary is more then $3000. Diplay proper message for tax.(DO it in your note book or port your solution here.)
Sir I'm lazy to do it in notebook so I just post comment for the HW ya sir.. haha..
ReplyDeleteAnswer for 3-
Step 0. Start
Step 1. Input A as Basic Salary
Step 2. Declare a Variable B for Hra
Step 3. Declare a Variable C for Da
Step 4. Calculate Hra, B=(10/100)*A
Step 5. Calculate Da, C=(15/100)*A
Step 6. Declare another Variable D as Net Salary.
Step 7. Calculate Net salary, D=A+B+C
Step 8. Check if Net salary greater than 3000
If yes,
Step 9. Display "Tax needs to be paid"
If no,
Step 9. Display "No tax will be imposed"