I have the following source code and for some reason I don't know how to use both in the same program. I know there is a void somewhere. Also I am having trouble outputting the data into a table, if I could get some help with that. Basically to where it reads Days on the left side and Number of Organisms on the right side (for up to 20 days).
#include <iostream>
using namespace std;
int main(){
int sum = 0
int input;
int i = 0;
cout << "Please enter a number: ";
cin >> input;
while(i<=input){
sum = sum + i;
i++;
}//end while loop
cout << endl << "The sum is: " << sum << endl;
return 0
}//end main function
//end program
#include <iostream>
using namespace std;
int main(){
int organisms;
double reproduceRate;
int days;
cout << "What is the initial number of organisms: ";
cin >> organisms;
if(organisms < 2){
cout << "Invalid, try again." << endl;
cout << "What is the initial number of organisms: ";
cin >> organisms;
}
cout << endl << "What is their reproduce rate as a percentage: %";
cin >> reproduceRate;
if(reproduceRate < 0){
cout << "Invalid, try again." << endl;
cout << endl << "What is their reproduce rate as a percentage: %";
cin >> reproduceRate;
}
A program can have only 1 main() function (as far as I know). You could possibly split them into two separate functions and run any one depending on the user's choice though.
Its hard to understand what your trying to do, if you need both calculations in a single program just take the first code and copy it into the second program as a function then call the function if needed.
Your first program seems independant of the second one.