Just a reminder, the Fibonacci sequence is as follows... 0, 1, 1...

  1. Home
  2. Homework Library
  3. Computer Science
  4. Linux
  5. Just a reminder, the Fibonacci sequence is as follows... 0, 1, 1...

QuestionQuestion

Just a reminder, the Fibonacci sequence is as follows...

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ....

Any Fibonacci number in this sequence is the sum of the previous two numbers, starting with 0 and 1.

YOUR MISSION....

Write a program that continuously computes Fibonacci numbers and displays them on command when the appropriate signal is sent to it.

SO...

The program computes 0, waits 3 seconds, computes 1, waits 3 seconds, computes 1, waits 3 seconds, computes 2, waits 3 seconds, computes 3, etc....

NOW...

The program displays the latest Fibonacci number generated when the user sends the interrupt signal ( SIGINT ) by hitting control-C.

The program should display the latest generated Fibonacci number, clean up after itself by restoring any changed terminal driver settings, and then terminate when the user sends the quit signal ( SIGQUIT ) by hitting control-.

The program should not display ^C. The solution to this must be done programmatically. Using stty is not an option.

Do not use recursion in your solution.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

int main(int argc, char** argv) {
   
    // set up a, b and c
    int a=0,b=1;   
    c = 0;
    // set up condition to run the loop
    ends = 1;
            
    // setup signal handling
    signal (SIGINT, interrupt);   /* Ctrl-C    */
    signal (SIGQUIT, quit);       /* Ctrl-\    */   
   
    tty_mode(0); /* save current mode*/
    set_cr_noecho_mode(); /* set –icanon, echo */
   
    while (ends) { /* loop until ends = 0 */
       c= b + a;
       a = b;
       b = c;
       sleep(3);      
    }...

By purchasing this solution you'll be able to access the following files:
Solution.c.

$50.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Linux Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats