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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started