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


Please Help Members By Posting Answers For Below Questions

Discuss the effects occur, after an exception thrown by a member function is unspecified by an exception specification?

843


How many ways can a variable be initialized into in C++?

795


What is an inclusion guard?

857


Difference between pass by value and pass by reference?

850


What is a c++ map?

946


Difference between pointer to constant vs. Pointer constant

824


What is the use of lambda in c++?

771


When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?

834


How do you master coding?

810


Should a constructor be public or private?

756


Why namespace is used in c++?

792


What do you mean by friend class & friend function in c++?

814


What is a map in c++?

785


What operator is used to access a struct through a pointer a) >> b) -> c) *

855


What's c++ used for?

842