I am starting with a user input (a whole number). The goal is to us a loop to decrement the input number by 10. What I want to out put is the final number of iterations ONLY.
#include <iostream>
usingnamespace std;
int main()
{
int ticketsWon;
int num; num = 0;
//ask user to input number of tickets won
cout << "Enter the number of tickets you won: ";
cin >> ticketsWon;
//if number entered is >= 10 subtract 10
while(ticketsWon >= 10)
{
ticketsWon = ticketsWon - 10;
cout << "Candy Bars = " << ++num << " \n";
}
return 0;
}
It's basically doing what I want, except it's printing every iteration. Like this: