- May 26, 2005
- 2,141
- 3
- 81
Here is the question i have
Using a for loop, modify the code below so that it loops a total of 3 times.
#include <iostream>
using namespace std;
int main()
{
// Prompt the user to enter an integer
int number;
cout << "Enter an integer: ";
cin >> number;
if (number % 2 == 0)
cout << number << " is even.";
if (number % 2 != 0)
cout << number << " is odd.";
return 0;
}
what i dont understand is....where exactly should i put the loop, and in what format
(i = 0; i <= 3; i++) ?
Using a for loop, modify the code below so that it loops a total of 3 times.
#include <iostream>
using namespace std;
int main()
{
// Prompt the user to enter an integer
int number;
cout << "Enter an integer: ";
cin >> number;
if (number % 2 == 0)
cout << number << " is even.";
if (number % 2 != 0)
cout << number << " is odd.";
return 0;
}
what i dont understand is....where exactly should i put the loop, and in what format
(i = 0; i <= 3; i++) ?