82.7k views
5 votes
Write a program in QBASIC to display the first 10 numbers of the fibonacci series:

0,1,1,2,3,5,... up to 10 terms.

(Hint- Take the first two numbers 0 and 1. Now obtain the next number by adding them. For example:0+1=1)

User Wilhelm
by
4.3k points

1 Answer

7 votes

Answer:

#include<iostream>

using namespace std;

int main()

{

int a=0,b=1;

int i,c;

cout<<a<<" "<<b<<" ";

for(i=3;i<=10;i++)

{

c=a+b;

cout<<c<<" ";

a=b;

b=c;

}

return 0;

}

Step-by-step explanation:

Write a program in QBASIC to display the first 10 numbers of the fibonacci series-example-1
User Aleks G
by
5.3k points