Loop counter advice

Still working on the same code that I asked previously, and onto a new task:

I now need to add a counter to the main() that will keep track of how many times it processes an employee and displays this amount in the end.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
   int main()
{  
   count = 0;
   
     sum = 0;
   do{
   ......
      get_yesno ("Process another employee", answer);

   } while (yesno == 'Y'); {
            count = 1;
   }
    sum = count + count;
    std::cout << "total count is" << sum << std::endl;
}


The part I added is after the 'while - yesno' part.

I'm not really sure as to where to place this counter or did I even have the right formula for it.

Any advice would be helpful. Thank you.
Last edited on
When you process an employee, you can just use the post-increment count++ or pre-increment ++count, however you decide to work on your code. You don't need a separate variable for count at this point, since count will be the sum. After the while loop, you can just std::cout << "total count is" << count<< std::endl;
Thank you, you've been a great help.

Topic archived. No new replies allowed.