Hi there, I am VERY new to programming and I was wondering if there was a way to count the attempts it took a user to guess a correct number (in a while loop) and then display that number back to the console?
int count = 0; while (condition) { //do something ++count; //this line increase the count every time the loop is called }
++count or count++ is depends on what of calculation or logic you are coding! because they works in different way!
That's right unless neccessary, I usually used pre-increment, ++count; because it performs less calculations hence it is much faster....