Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ For Loop: Output evens #include using namespace std; int main() { int n; int i; cout > n; cout /* Type your code here.
c++
For Loop: Output evens
#include
int main() { int n; int i;
cout > n;
cout
/* Type your code here. */
return 0; }
(1) Given positive integer n, write a for loop that outputs the even numbers from n down to 0. 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: 7 Sequence: 64 20 (2) If n is negative, output 0, Hint: Use an if statement to check if n is negative. If so, just set n = 0. Enter an integer: -1 Sequence: 0Step 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