0 1 1 2 3 5 8 13 21 34 and so on.
Alogrithm:
- Read the LIMIT
- SET First = -1 and Second = 1
- LOOP until Second is greater than or equal to LIMIT
- SET Sum = First + Second
- Display the value of Sum to ouput screen.
- SET First = Second
- SET Second = Sum
- END LOOP
CodeListing
/*********************************************
Program: Roots of Quadratic Eqn.
Author : Vanangamudi
*********************************************/
#include
#include
int main()
{
int first,second,sum;
int limit ;
cout<<"Enter the Limit\t:" ;
cin>>limit ;
first=-1; second=1 ;
while(sum<=limit)
{
sum = first + second;
cout<
first = second ;
second = sum ;
}
getch() ;
}
0 comments:
Post a Comment