0% found this document useful (0 votes)
12 views5 pages

Assignment 1

The document discusses generating a Fibonacci series using recursion in C/C++. It includes code to declare variables, get user input for the number of terms, print the initial terms, and loop to calculate and print subsequent terms using recursion.

Uploaded by

BIPANSHU KUMAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

Assignment 1

The document discusses generating a Fibonacci series using recursion in C/C++. It includes code to declare variables, get user input for the number of terms, print the initial terms, and loop to calculate and print subsequent terms using recursion.

Uploaded by

BIPANSHU KUMAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Subject : Data Structure

Subject code : CS -215

Sant Longowal Institute of


Engineering & Technology,
Longowal

Name : Bipanshu Kumar -1-


Reg no : 2010264
Semester : 3rd
Subject : Data Structure
Subject code : CS -215

Write a program in C/C++ to generate


fibonacci series using recursion.

Code :
#include <stdio.h>
int main()
{

int first = 0, second = 1, sum = 0, n;

printf("Enter the end term for the series: ");


scanf("%d", &n);

printf("\nFibonacci Series: %d, %d, ", first, second);

sum = first + second;


while(sum <= n)
{

Name : Bipanshu Kumar -2-


Reg no : 2010264
Semester : 3rd
Subject : Data Structure
Subject code : CS -215

printf("%d, ",sum);
first = second;
second = sum;
sum = first + second;
}

return 0;
}

Name : Bipanshu Kumar -3-


Reg no : 2010264
Semester : 3rd
Subject : Data Structure
Subject code : CS -215

Name : Bipanshu Kumar -4-


Reg no : 2010264
Semester : 3rd
Subject : Data Structure
Subject code : CS -215

Output :

Name : Bipanshu Kumar -5-


Reg no : 2010264
Semester : 3rd

You might also like