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
Why can’t you call invariants() as the first line of your constructor?
Explain data encapsulation?
Are strings immutable in c++?
What is stream and its types in c++?
Why ctype h is used in c++?
What are the advantages of prototyping?
What is a down cast?
What is linked list in c++?
Explain rtti.
What is the need of a destructor? Explain with the help of an example.
What is the auto keyword good for in c++?
What are vtable and vptr?
How do you establish a has-a relationship?
Can you please explain the difference between using macro and inline functions?
Is swift better than c++?