In JAVA with OUTPUT
Write a program to display the first 10 Fibonacci numbers
Answers
Answered by
4
Answer:
This is the required Java program for the question.
public class FibonacciSeries {
public static void main(String args[]) {
int a=1,b=0,c=0,i=1;
for(;i<=10;i++) {
System.out.print(c+" ");
c=a+b;
a=b;
b=c;
}
}
}
Algorithm:
- START.
- Initialise a=1, b=0, c=0
- Iterate loop 10 times.
- Display c
- Add the sum of a and b and store in c.
- Store the value of b in a.
- Store the value of c in b.
- STOP.
Refer to the attachment.
•••♪
Attachments:
Similar questions