Saturday, March 23, 2019

Number to keep on adding in a while loop (C++)

#include 
using namespace std;

int main () {

int n = 100;

while (n > 50) {

cout << n << ", ";

--n;

}

cout << "DONE!";

system("PAUSE");

}



Basically, this program will put the integer in a while loop and keep on subtracting one until it reaches 50, but I want it to do the opposite. Instead of --n (which keeps on subtraction one from the value), I want it to add one.



Okay, so how would you do this with multiplication? Because **n isn't working...?

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...