Write the program for fibonacci in c++?
Answer Posted / raaz
#include "stdafx.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
int range = 0;
cout<<"Enter the range of numbers\n";
cin>>range;
for(int i = 0;i<range;i++)
{
int outNum[100];
if((i==0)||(i==1))
{
outNum[i] = i;
cout<<outNum[i]<<" ";
}
else
{
outNum[i] = outNum[i-1] + outNum[i-2];
cout<<outNum[i]<<" ";
}
}
return 0;
}
Is This Answer Correct ? | 13 Yes | 33 No |
Post New Answer View All Answers
What is near, far and huge pointers? How many bytes are occupied by them?
How do you show the declaration of a virtual constructor?
What is static function? Explain with an example
What is the difference between multiple and multilevel inheritance in c++?
What is the syntax for a for loop?
On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?
What is lvalue?
Can we declare a base-class destructor as virtual?
Give example of a pure virtual function in c++?
Explain method of creating object in C++ ?
What is dynamic and static typing?
What is the return value of the insertion operator?
What is a wchar_t in c++?
Why do we use classes in c++?
What is c++ library?