Create a for loop that counts from 100 down to 1. In the loop, print out each number. If the number is even, print "---Even". Use the appropriate printing commands (setw, precision, ext) to insure that the ---Even statements are indented exactly 7 characters from the left margin.
Sample output:
100 ---Even
99
98 ---Even
this is the question that i got.
It requires the space from the very beginning of the line to "---Even" is exactly 7 character.
This is what I did so far.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <iomanip>
usingnamespace std;
int main (){
int count;
for (count = 100; count >=1 ; count--)
if (count %2 == 0){
cout << count << setw (7) << "---Even" << endl;
}
else
cout << count << endl;
system("pause");
return 0;
}