Loops assignment

Can someone help me with this C++ programming. I use linux through putty to do this.

Create a C++ program which outputs the first four powers of three and then counts down by three. The output should look like this:


Counting up by powers of three...

1

3

9

27

Counting down by threes...

27

24

21

18

15

12

9

6

3

0

Done!
1
2
3
4
5
std::cout << "1\n";
for(int i = 1; i < 27; i = i * 3)
    std::cout << i << '\n';
for(int j = 30; i > 0; i = i - 3)
    std::cout << i << '\n';

Might need tweaking, cant test because my c++ environment is dead.
Topic archived. No new replies allowed.