Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3.a. while loop (1.5 marks) This loop will find the overflow of a division opera

ID: 3878276 • Letter: 3

Question

3.a. while loop (1.5 marks) This loop will find the overflow of a division operation. Instruction: Create a function named overflow to calculate the how far the closest multiple of the divisor is relative to the dividend. If the divisor is greater than the dividend, the dividend is returned. Do not worry about having a divisor of 0, although any negative dividends should be converted to a positive. e. . the overflow of 25/6 is 30-25-5 . the overflow of-14/9 is 18-14-4 (This is treated as overflow 14/9) the overflow of 3/28 is 3 There is a skeleton of the control flow to get you started, you just need to fill in the missing sections. There is also an absolute value function required for the overflow calculation that must be completed.

Explanation / Answer

Based on the description , given below is the code for overflow() function. Use this in your full code. But remember, this function expects that the absoluteValue() function is completed first. I have checked this code by replacing absoluteValue() with abs() from stdlib.h and it works as intended. Let me know if any issues with the code. Please do rate the answer if helpful. Thank you.

int overflow(int dividend, int divisor){
int remainder;
int currentValue;
  
dividend = absoluteValue(dividend);
  
if(dividend < divisor){
remainder = dividend;
}
else {
currentValue = divisor;
while(currentValue < dividend){
currentValue += divisor;
}
remainder = currentValue - dividend;
}
return remainder;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote