HSC Science (Computer Science) 12th Board ExamMaharashtra State Board
Share

# Write Program in C++ to Print First 20 Terms of Fibonacci Series (Series Is 0, 1, 1, 2, 3, 5, 8 .......... ) - HSC Science (Computer Science) 12th Board Exam - Computer Science 1

#### Question

Write program in C++ to print first 20 terms of Fibonacci Series (Series is 0, 1, 1, 2, 3, 5, 8 .......... )

#### Solution

//Program to generate 20 terms of fibbonacci series
void main()
{
int f0, f1, f, n;
f0 = 0;
f1 = 1;

cout <<"Fibbonacci Series :";
cout << f0;
cout << f1;
for (n = 2; n < 20; n++)
{
f = f0 + f1;
cout << f;
f0 = f1;
f1 = f;
}
}​
//Program to generate 20 terms of fibbonacci series
void main()
{
int f0, f1, f, n;
f0 = 0;
f1 = 1;

cout <<"Fibbonacci Series :";
cout << f0;
cout << f1;
for (n = 2; n < 20; n++)
{
f = f0 + f1;
cout << f;
f0 = f1;
f1 = f;
}
}
Is there an error in this question or solution?

#### APPEARS IN

2015-2016 (March) (with solutions)
Question 5.1.1 | 5.00 marks
Solution Write Program in C++ to Print First 20 Terms of Fibonacci Series (Series Is 0, 1, 1, 2, 3, 5, 8 .......... ) Concept: C++ Programming.
S