Question

* Write a Java program that calculates and displays the
Fibonacci numbers

* First prompt the user to input a number, N

* Then use a for loop to calculate and display the first N
fibonocci numbers

* For example, if the user enters 5, the output should be:

* 1, 1, 2, 3, 5

*

* if the user enters 10, the output should be:

* 1, 1, 2, 3, 5, 8, 13, 21, 34, 55

Answer #1

```
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
int n;
n=s.nextInt(); //Taking the input
int first = 1, second = 1; //Since first 2 terms are 1 and 1
//For loop
for(int i=0;i<n;i++){
System.out.print(first + " ");
int temp = first + second; //next term in the sequence is sum of last two
first = second; //For next step 2nd term is first term
second = temp; //For next step the next term is the second term
}
}
}
```

Written in MASM Assembly
Problem Definition:
Write a program to calculate Fibonacci numbers.
• Display the program title and programmer’s name. Then get the
user’s name, and greet the user.
• Prompt the user to enter the number of Fibonacci terms to be
displayed. Advise the user to enter an integer in the range [1 ..
46].
• Get and validate the user input (n).
• Calculate and display all of the Fibonacci numbers up to and
including the nth...

Please Write the whole program in assembly i am able to
calculate the fibonacci series but not sure how to print it in
reverse order. Please give a Complete code !!
Programming Exercise 1 (10 points): [call it
Ass2-Q1.asm] Write an ASM program that reads an integer number N
and then displays the first N values of the Fibonacci number
sequence, described by: Fib(0) = 0, Fib(1) = 1, Fib(N) = Fib(N-2) +
Fib(N-1)
Thus, if the input is N...

Write a c++ program that evaluates the first 50 numbers of the
Fibonacci sequence and store the numbers in an array.
The c++ program asks the user for an input to enter a positive
integer 'n' and display the nth fibonacci number "FibN" that is
stored inside of the array

In mathematics, the Fibonacci numbers are the numbers in the
following integer sequence, called the Fibonacci sequence, and
characterized by the fact that every number after the first two is
the sum of the two preceding ones:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, …
The sequence Fn of Fibonacci numbers is defined by
the recurrence relation:
Fn = Fn-1 + Fn
with seed values F1 = 1 F2 = 1
For more information on...

Write a Java program that gets a 4x4 array of numbers and that calculates the sum and average of numbers on the main diagonal, ie the diagonal that goes from the left corner down to the right corner.
Examples of resulting programs are:
Enter a 4x4 matrix row by row:
1 2 3 4
5 6 7 8
9 1 2 3
4 5 6 7
The sum of numbers in the diagonal is: 16
The average of numbers in...

WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question,
DO ADD COOMENTS AND DISPLAY THE OUTPUT OF A RUNNING COMPILER
QUESTION:
1) Fibonacci sequence is a sequence in which every number after
the first two is the sum of the two preceding ones. Write a C++
program that takes a number n from user and populate an array with
first n Fibonacci numbers.
For example:
For n=10
Fibonacci Numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
2):
Write...

In mathematical terms, the sequence Fn of Fibonacci numbers is
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..
Write a function int fib(int n) that returns Fn. For example, if
n = 0, then fib() should return 0,
PROGRAM: C

Write a VSC (macro) program that computes and displays a
Fibonacci sequence. A Fbonacci sequence is generated by adding the
two most recent sequence numbers together, i.e., 1, 1, 1+1-2,
1+2=3, 2+3=5, 3+5=8, … The user will enter the number of terms in
the sequence to be displayed. Assemble this program using the VSC
assembler (ASM), and simulate this program using the VSC simulator
(SIM). Include a copy of the source listing (SOURCE.DAT), the
assembled listing (SLIST.DAT) and the simulation...

Write a Java program called Decision that includes a while loop
to prompt the user to enter 5 marks using the JOptionPane statement
and a System. Out statement to output a message inside the loop
highlighting a pass mark >= 50 and <= 100. Any other mark
will output a messaging stating it’s a fail.
Example of the expected output is as follows:

4) Write a Java program using Conditions: Write a program where
it will ask user to enter a number and after that it will give you
answer how many digits that number has.
Steps: 1) Create Scanner object and prompt user to enter the
number and declare variable integer for input
2) Use if else condition with && condition where you
will specify the digits of numbers by writing yourself the digit
number that should display: Example(num<100 &&
num>=1), and...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 12 minutes ago

asked 24 minutes ago

asked 27 minutes ago

asked 28 minutes ago

asked 36 minutes ago

asked 37 minutes ago

asked 41 minutes ago

asked 45 minutes ago

asked 45 minutes ago

asked 57 minutes ago

asked 1 hour ago

asked 1 hour ago