0% found this document useful (0 votes)
32 views

Internet Programming Lab 2

NA

Uploaded by

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

Internet Programming Lab 2

NA

Uploaded by

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

Experiment 2

Student Name: Dimpal Sharma UID:20BCA1236


Branch: BCA Section/Group:3/B
Semester: Fourth Date of Performance:27-02-2022
Subject Name:Internet Programming Lab Subject Code:20CAP-255

1. Aim/Overview of the practical: To Write a Java program.

2. Task to be done:

Write a java program that uses both recursive and non-recursive functions to print the n th value in the
Fibonacci sequence.

3. Algorithm/Flowchart :
Algorithm to generate fibonacci series
First two terms of fibonacci series is 0 and 1.
we will store the last two terms of fibonacci series in "last" and "secondLast" integer variable.
Current term of fibonacci series is equal to the sum of "last" and "secondLast" term.(current = last + secondLast)
Update last and secondLast variable as secondLast = last; and last = current;

4. Dataset:

import java.util.Scanner;

class Main
{
public static void main(String args[])
{
System.out.println("Enter the number n to print the faboniccs series ");
Scanner ob=new Scanner(System.in);
short a=ob.nextShort();
Series ob1=new Series();
long b=ob1.input(a);
System.out.println("The "+a+"th number of the faboniccs series is "+b);
}
}

class Series
{

int a=1;
int b=1;
int c=0;
int count;
int input(int a)
{
count=a;
count=fabo(count);
return count;
}

int fabo(int count)


{
if(count!=2)
{
c=a+b;
a=b;
b=c;
fabo(--count);
}
return c;
}
}

5. Code for experiment/practical:


6. Result/Output/Writing Summary:
Here we simple write a value for n like we write n=10 then press enter button compiler
show me faboniccs series.

Learning outcomes (What I have learnt):

1. I understand that how to use java program.

2. I understand what is Scanner Class in java and what is its uses.

3. I learnt that what is algorithm to find uses both recursive and non-recursive functions to print
the nth value in the Fibonacci sequence.

4.

5.

Evaluation Grid:
Sr. No. Parameters Marks Obtained Maximum Marks
1. Demonstration and Performance 5
2. Worksheet 10
3. Post Lab Quiz 5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy