Question: Write a C program that will get input from the user (e.g. using scanf, fgets, etc.).Your program will convert valid input from the user (only

Write a C program that will get input from the user (e.g. using scanf, fgets, etc.).Your program will convert valid input from the user (only positives integers greater than zero) and return the answer. If the user input anything other than a positive integer then immediately print out an error message.

There will only be three options, which are the following:

1. Print out your name.

2. Print out the i-th Fibonacci number. Please use recursion so that it is slower.

3. Exit the program. However, before doing so, terminate all existing pthreads that are currently running before exiting.

In the first two cases you will spawn a new thread to either print your name or print out the i-th Fibonacci number. Our program will start with a 0 in the sequence.Do not wait for the answer to be generated before waiting for new input. Continue to get input from the user until the user enters "3" then exit the program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!