36: W.A.P. to display Fibonacci series 1, 1, 2, 3, 5, 8,
........
Please follow me for more practicals....
Program:
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int num, a = 1, b = 0, sum = 0;
printf("Enter the num = ");
scanf("%d", &num);
for (int i = 1; i <= num; i++)
{
sum = a + b;
printf("%d\t", sum);
a = b; b = sum;
}
getch();
}
Please follow me for more practicals....
Output:
Enter the num = 6
1 1 2
3 5
8
Please follow me for more practicals....
Algorithm:
1.
START
2.
Declare num, a = 1, b = 0, sum = 0, i = 1.
3.
Enter the num.
4.
Repeat up-to step-8 until i <= num.
5.
Sum = a + b.
6.
Display sum.
7.
a = b, b = sum.
8.
i++.
9.
STOP.
Please follow me for more practicals....
Flowchart: