Question: USER DEFINED FUNCTIONS! C++! Example 3: // this function receives the lower and upper boundaries of a range of whole numbers and a divisor. It

USER DEFINED FUNCTIONS! C++!

Example 3:

// this function receives the lower and upper boundaries of a range of whole numbers and a divisor. It returns the // algebraic addition of all the numbers within the specified range (boundaries included) processed according to the // following rules: // -if the number being processed is divisible by the divisor received, the number is ADDED to the accumulated value // -if the number being processed is NOT divisible by the divisor received, the number is SUBTRACTED from the // accumulated value

magicNumber( ) {

}

int main( ) { // declare variable(s)

// prompt the user to enter the range's lower and upper boundaries // get the values and store them in the corresponding variables // prompt the user to enter the divisor // get the values and store them in the corresponding variables

// display the magic number (must call the function to get it)

}

OUTPUT:

enter a valid range (first value smaller than second value) and a valid divisor (not zero)

Please enter the range's lower and upper boundaries: 1 50 Please enter the divisor: 3

The magic number is: -459 

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!