New to C++

Sep 24, 2010 at 9:28pm
No doubt this question is going to elementary but I'm just starting to learn the language, but for a class I'm supposed to design a program that

"computes the rate of growth, expressed as a percentage, of an insect population. Take as input the initial size of the population and its size one week later. Then compute the rate of growth and predict the size of the population in yet another week, assuming that growth continues at the same rate."

At the moment, I currently have

#include <iostream>

Using namespace std;

int main() //start of main function
{
int x; //Declaring x for initial population size
int y; //Declaring y for population size on week 2

cout << "Enter Population Size For Week 1: ";//enter initial population size
cin >> x; //Sends input of population to variable x
cout << "Enter Population Size For Week 2: "; //enter population size for week 2
cin >> y; //sends input of week 2 to variable y

endl;
}

I apologize for the sloppiness of the post, but like I said, I'm just starting to try and get the hang of everything.

Can anyone help me on what I'm doing wrong or how to improve this?
Sep 24, 2010 at 9:37pm
Just think of doing it without programming.
Say the first population is 100.
The second population is 150.

Divide the second by the first and you get 1.5.
Thus the next week would be 150 x 1.5.

Then try to convert it to code.
Sep 24, 2010 at 10:10pm
ALright, thank you, that definitely helps.

But just to make sure I'm on the right track I try to 'start without debugging' but the option isn't available to me to execute, would you know why?
Sep 24, 2010 at 11:45pm
So the code is compiled and you can debug it, but you can't start without debugging it?
If so, I haven't heard about that before so I can't really help with that =/.
Topic archived. No new replies allowed.