Question: Question 1 Write a program in C which first initializes an integer variable to a random value between 100 and 200. By using signal() system

Question 1 Write a program in C which first initializes an integer variable to a random value between 100 and 200. By using signal() system call for SIGINT, alter the behaviour of Ctrl-C such that whenever this combination is pressed, the program switches between adding or subtracting 10 from this variable in an endless loop with 1 second delays. Your program must indicate whether it is increasing or decreasing the variable and it must end if value of the variable is below 100 or above 200.

Sample Run $ ./question1

[Increasing]

Variable: 188

Variable: 198

[Decreasing]

Variable: 188

Variable: 178

Variable: 168

[Increasing]

Variable: 178

Variable: 188

Variable: 198

Variable: 208

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!