My previous post was on C language was about understanding IF condition.
Now lets try and understand Algorithm of nested if condition and iterative if condition
Nested if else condition for finding the highest among the three numbers a, b and c.
- Start.
- Accept the value a, b, c.
- If a>b and a>c then
- Display a as greatest.
- Go to step 14.
- If a>b and a<c then
- Display c as greatest.
- Go to step 14.
- If a<b and b>c then
- Display b as greatest.
- Go to step 14.
- If a<b and b<c then
- Display c as greatest.
- End.
Now in the above algorithm even if the values of a and b or a and c or either of two values or all values of a,b and c are equal we can get the answer through it.
Through if condition we can work out the algorithm of Tables
- Start.
- Accept the value of a.
- Let b = 1.
- c = a × b.
- Express (display or print) c.
- Increment value of b by 1.
- If b <= 10 then go to step 4.
- If b >= 11 then go to step 9.
- End.
Focus on the above algorithm and remember that step 4, 5 and 6 are repeated till the value of b < 10 and as b goes beyond 10, step 8 executes and algorithm terminates. As you can observe carefully the recurrence of step 4, 5 and 6 is due to variance in the value of b. b is initialized in step 3, condition is checked for b in step 7 and value of b is incremented in step 6
Last 5 posts in C simplified
- Simplest way to learn C Language: Coding in C language made easy - June 30th, 2010

{ 1 trackback }