Saturday, 23 March 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...