Is it possible to increment using ++ besides the number one?

Hey all. Worlds worst programmer here. I have some issues regarding this latest torture.........oops I meant assignment. I'm basically researching data online about world population growth for the next seventy years and output the info. Now, considering that ideally, I would like to skip having to print out the full 75 years worth of data onto the program, I decided to create a while loops.

The only problem I ran into, is that for some reason, it wasn't incrementing the rather large number of yearly population increase. For the sake of making this program as simple as possible, is it possible to create a sort of exponential increment? The code is below. Any pointers would be great.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  // Lab 2c, Tabular Formatting
// Programmer: Jesse Burns
// Editor(s) used: JNotePad
// Compiler(s) used: VC++ 2010 Express
// The necessary C++ file library
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::ios;

#include <string>
using std::string;
using std::getline;

#include <iomanip>
using std::setw;
using std::setprecision;
using std::left;
using std::right;

#include <cstdlib>

int main()
{
  // Jesse Burns, Lab 2c.
  cout << "Lab 2c, Tabular Formatting\n";
  cout << "Programmer: Jesse Burns\n";
  cout << "Editor(s) used: JNotePad\n";
  cout << "Compiler(s) used: VC++ 2010 Express\n";
  cout << "File: " << __FILE__ << endl;
  cout << "Compiled: " << __DATE__ << " at " << __TIME__ << endl << endl;

  //The variables needed to show initial year population and subsequent growth
  long long totalpop = 7209120128;
  long long growthyear = 100927654;
  long long growthplus;
  int loop = 1;
  int year = 2013;

  //The cout for header
  cout << "World Population Growth estimate for next 75 years." << endl;
  cout << "------------------------------------------------------" << endl;

  //A while loop to increment the year and population up to seventy five years.
  while (loop <= 75)
  {

  //The math needed for conversion
  loop++;
  growthplus = totalpop + growthyear;
  year++;

  //The cout necessary to show that year to year growth.
  cout << year << setw(21) << growthplus <<endl;
  }
}
Technically speaking you aren't doing an exponential growth you are doing a linear growth. So you could simply do

TotalPop = InitialPop + YearsPassed * GrowthPerYear; Not sure if this is what you are asking or not though.


*edit

wait a second...You aren't even incrementing each time..I was thinking it said growthyear = totalpop + growthyear;

growthplus = totalpop + growthyear;

You never increment the totalpop or growthyear.
Last edited on
Yeah, nevermind, I fixed it. I'll delete the thread.
Topic archived. No new replies allowed.