
I-78 Computer Fundamentals
Step 3: Read n
Step 4: While i <= n
Read num
Add num to sum
Increment i by 1
End while
Step 5: Calculate Average = Sum / n
Step 6: Display Average
Step 7: Stop
26. Write an algorithm to generate a Fibonacci series.
Ans:
Step 1: Start
Step 2: Initialize sum=0, A=0, B=1, i=3
Step 3: Read the number of terms you want in the Fibonacci
series, say n
Step 4: Display A, B
Step 5: While i <= n
Add A and B and store value in sum
Display sum
Assign the value of B to A, that is, A=B
Assign the value of sum to B, that is, B=sum
Increment i by 1
End while
Step 6: Stop
27. Write an algorithm to test whether the gi ...