I am new to programming and am trying to write a simple program that calculates the number of days it takes for a salary to earn 100,000 dollars. The pay rate doubles each day and is 0.01 the first day and 0.02 the second, and 0.04 the next..and so on. I was able to get the loop to 100,000, but i do not know how to keep up with how many times it took to reach >= 100000. any help would be great!
This is pretty easy solution. You've already done all of the hard work. You just need to declare a counter variable. You'll want to initialize this to 0, and place at the end of your loop. You could do something such as...
1 2 3 4 5
counter = counter + 1;
//or
counter++;
Every pass through the loop will increment the value of counter by 1 every time. When you've reached your desired amount, you can then create an output using this variable.