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 buffering in c++?
Is java the same as c++?
What are the methods of exporting a function from a dll?
What do manipulators do?
How do I start a c++ project?
How long does it take to get good at leetcode?
what is oops and list its features in c++?
Does c++ have finally?
What does extern mean in a function declaration in c++?
Can a program run without main function?
write a programme to get a character and thier ASCII value
What is a storage class used in c++?
If you want to share several functions or variables in several files maitaining the consistency how would you share it?
Using a smart pointer can we iterate through a container?
What will happen if a pointer is deleted twice?