#include<iostream.h>
#include<conio.h>
class fibo
{
public:
void fibonacci();
};
void fibo::fibonacci()
{
int t1 = 0, t2 = 1, nextTerm = 0, n;
cout << "\nEnter a positive number to calculate \nthe Fibonacci series upto entered number: ";
cin >> n;
cout << "\nFibonacci Series: " << t1 << ", " << t2 << ", ";
nextTerm = t1 + t2;
while(nextTerm <= n)
{
cout << nextTerm << ", ";
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
}
}
void main()
{
clrscr();
fibo ob;
ob.fibonacci();
getch();
}
This is good article. You can read more interesting top C Programming Practicals here.
ReplyDeleteThe site contains few practicals want more on bscit see hereBscIt Notes and study material.
ReplyDeleteThank you so much for sharing all practical information It really help to understand c++ in better way and also completing my practical keep it a bro you doing wonderful job... thank you so much
ReplyDelete