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
Discuss the effects occur, after an exception thrown by a member function is unspecified by an exception specification?
How many ways can a variable be initialized into in C++?
What is an inclusion guard?
Difference between pass by value and pass by reference?
What is a c++ map?
Difference between pointer to constant vs. Pointer constant
What is the use of lambda in c++?
When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?
How do you master coding?
Should a constructor be public or private?
Why namespace is used in c++?
What do you mean by friend class & friend function in c++?
What is a map in c++?
What operator is used to access a struct through a pointer a) >> b) -> c) *
What's c++ used for?