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
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
How much maximum can you allocate in a single call to malloc()?
Is c++ still in demand?
What is a buffer c++?
what is C++ objects?
What are the differences between new and malloc?
What is the sequence of destruction of local objects?
In a function declaration, what does extern mean?
Can we make any program in c++ without using any header file and what is the shortest program in c++.
Why struct is used in c++?
What does std :: flush do?
Can manipulators fall in love?
What is the use of bit fields in structure declaration?
Explain the benefits of proper inheritance.
Show the declaration for a static member variable.