Question: 1 7 . 2 2 PRACTICE: Loops ( for ) * : Output evens ( 1 ) Given positive integer n , write a for
PRACTICE: Loops for: Output evens
Given positive integer n write a for loop that outputs the even numbers from n down to If n is odd, start with the next lower even number. Hint: Use an if statement and the operator to detect if n is odd, decrementing n if so
Enter an integer:
Sequence:
If n is negative, output Hint: Use an if statement to check if n is negative. If so just set n
Enter an integer:
Sequence:
Note: For simplicity add a space after each output value, including the last value.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
