Multimedia & Design

All About Technology
login.php forums_m.php?mode=register faq.php memberlist.php search.php yuvzweb.html




Multimedia & Design Forum Index » PROGRAMMING SECTION » Fibonacci Sequence C++ Code
Post new topic  Reply to topic View previous topic :: View next topic 
Fibonacci Sequence C++ Code
PostPosted: Sun Apr 03, 2011 7:14 am Reply with quote
yhovenigdao
Site Admin
Joined: 19 Jan 2011
Posts: 7
Location: Cagayan do Oro City, Philippines




// Name: Fibonacci Sequence
// Description:This code prints 'The Fibonacci sequence'.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n[20],x;
cout<<"Enter the number of terms ";
cin>>x;
n[0]=0;
n[1]=1;
if(x==1)
{
cout<<n[0];
}
else
{
cout<<n[0]<<","<<n[1];
}
if(x>2)
{
for(i=2;i<=x-1;i++)
{
n[i]=n[i-1]+n[i-2];
cout<<","<<n[i];
}
}
getch();
}
View user's profile Find all posts by yhovenigdao Send private message Send e-mail Visit poster's website Yahoo Messenger
ForumsLand.com
PostPosted:  
Free Forum




Fibonacci Sequence C++ Code
Multimedia & Design Forum Index » PROGRAMMING SECTION
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Post new topic  Reply to topic  


Powered by phpBB © 2001-2004 phpBB Group
Designed for Trushkin.net | Themes Database