c++ loop for continuous adding

How do I make a loop with while or do while that can add until I reach 100 or over?
while (total < 100)
{
total = total + someAmount;
}
closed account (E0p9LyTq)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

int main()
{
   unsigned short top_num = 0;
   std::cout << "What number to count to? ";
   std::cin >> top_num;

   unsigned long long sum = 0;
   unsigned long long count_num = 0;

   // add up the all the numbers from 0 to top_num, inclusive
   while (count_num <= top_num)
   {
      sum += count_num;
      count_num++;
   }

   std::cout << "The total is: " << sum << '\n';
}

What number to count to? 278
The total is: 38781
What number to count to? 0
The total is: 0
Topic archived. No new replies allowed.