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
Explain the difference between c++ and java.
Write a Program for find and replace a character in a string.
Am studying basic c++ programming, have been given the following assignment. Design a linear program to calculate the maximum stress a material can withstand given a force and a diameter of a circle. To find the required area pi should be defined. Have most of the program sorted out but am at a loss as to how to show the calculations required. Can anyone help?
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
What is private, public and protected inheritance?
What return value must conversion operators have in their declaration?
How the keyword struct is different from the keyword class in c++?
What can I use instead of namespace std?
Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.
Why would you use pointers in c++?
Which operations are permitted on pointers?
How should a contructor handle a failure?
What is the arrow operator in c++?
What is a syntax in c++?
What are features of c++?