PROCEDURE:-
#include<stdio.h>
void main()
{
int i=3, a=0,b=1 ,c;
printf(“Fibonacci series below 100 are :\n”);
printf(“%3d %3d”,a,b);
while(i<=100)
{
c=a+b;
printf(“%3d”,c);
a=b;
b=c;
i++;
}
}
Output:- Fibonacci series below 100 are
0 1 1 2 3 5 8 13………………
- 1.set i to 3, set a=0,b=1,
- 2. repeat steps 3 to 5 until i is less than or equal 100 incrementing i by 1 each time
- 3. compute c=a+b
- 4.print value of c
- 5. set a=b,b=c
#include<stdio.h>
void main()
{
int i=3, a=0,b=1 ,c;
printf(“Fibonacci series below 100 are :\n”);
printf(“%3d %3d”,a,b);
while(i<=100)
{
c=a+b;
printf(“%3d”,c);
a=b;
b=c;
i++;
}
}
Output:- Fibonacci series below 100 are
0 1 1 2 3 5 8 13………………
Comments
Post a Comment