Question: Objective: write a program that provides a custom handler for the interrupt signal. What to do? Write a C program prime that uses a brute
Objective: write a program that provides a custom handler for the interrupt signal.
What to do?
Write a C program prime that uses a brute force approach to find prime numbers.
prime needs to keep track of the largest prime number found so far.
Use the signal() function to provide a custom handler for the SIGINT signal.
When Ctrl-C is pressed, prime needs to do the following:
Print the largest prime number found so far;
Prompt the user whether to quit;
Accept exactly one character as the input without requiring the user to press Enter;
Quit if the user presses y or Y.
Typical output generated by prime will look as follows:
$ prime 17 Quit [y/n]? n 271 Quit [y/n]? z 521 Quit [y/n]? N 1061 Quit [y/n]? n 1783 Quit [y/n]? y $
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
