Question
C++ Write a function stepSizePrint . This function takes three integer parameters: a starting point, an ending point, and a step size. This function should
C++
Write a function stepSizePrint. This function takes three integer parameters: a starting point, an ending point, and a step size. This function should print out all the numbers between the starting point and the ending point with intervals of the step size.
-
Your function should be named stepSizePrint
-
Your function should take three integers: starting point, ending point, and step size. They must be in this order.
-
Your function should not return anything.
-
Your function should print/output one number each line as described above.
Note:
- You do not need to write the main(), the include, or namespace commands, you only need to write the function definition.
- When step size is positive, the ending point needs to be larger than the starting point; if the step size is negative, the ending point should be smaller than the starting point. Any inputs that do not meet this requirement should print:
Wrong settings!
- The step size needs to be non-zero. When step size is zero, please print:
Step size cannot be zero.
- When printing out the numbers, you should always include the starting point but exclude the ending point.
- See examples below.
For example:
Test | Result |
---|---|
stepSizePrint(0, 5, 2); | 0 2 4 |
stepSizePrint(0, 5, -2); | Wrong settings! |
stepSizePrint(-3, -10, -2); | -3 -5 -7 -9 |
stepSizePrint(0, 4, 2); | 0 2 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started