Question: Write a function called safeIncrement ( var , limit ) that will increment the variable var if doing so will not cause it to exceed

Write a function called safeIncrement(var, limit) that will increment the variable var if doing so will not cause it to exceed the limit.The parameter var should be a pointer to the integer variable to increment. limit should be an integer giving the maximum value. The function should return 1 if it was able to increment the variable, or 0 if it could not.An example of how your function will be used is:int movement_needed(); // Function to check sensor and show if arm movement neededvoid move_arm(int); // Function to move the robot armint arm_position =0; // Position of a robot arm which must be between 0 and 5while (movement_needed()){ if (safe_increment(&arm_position, 5)==1) move_arm(arm_position);}
Please note: you should not write a main() function. Assume that all necessary #include statements, the main function, and the printf statements to display output have all been implemented. You should write only the safe_increment function

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!