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 virtual methods?
Are strings mutable in c++?
How can I learn dev c++ programming?
What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack
Write a program using GUI concept for the scheduling algorithms in Operating system like SJF,FCFS etc..
What is constructor in C++?
How would you find out if a linked-list is a cycle or not?
A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.
What's the most powerful programming language?
What is an html tag?
What is the difference between a type-specific template friend class and a general template friend class?
What data encapsulation is in c++?
What are inline functions? What is the syntax for defining an inline function?
Is nan a c++?
Write a function to find the nth item from the end of a linked list in a single pass.