#Help formatting a for loop.
16 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
!sc
Please Do Not Send Screenshots!
They're hard to read and prevent copying and pasting.
whats the command for pasting the code in discord style
and to align things nicely, you're most likely looking for std::setw
How to Format Code on Discord
Markup
```cpp
int main() {}
```
Result
int main() {}
oh wrong one
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//program code goes here
int startingPop;
int increase;
int days;
int day;
cout << "Lovebug Population Estimator\n\n";
cout << "Enter the starting number of lovebugs: ";
cin >> startingPop;
if (startingPop < 2)
{
cout <<
}
cout << "\nEnter the average daily percent increase (%): ";
cin >> increase;
increase = increase / 100;
cout << "\nEnter the number of days to multiply: ";
cin >> days;
cout << "\n\nDay\tPopulation\n";
for (day = 1; day <= days; day++);
{
cout << day << "\n";
}
system("pause");
return 0;
}
i also changed that first if statement to be able to validate input better and not break the program haha
for (day = 1; day <= days; day++);
{
cout << day << "\n";
}
how would i get this to print out like 1, 2, 3, 4...etc until it hits "days" which would be a user input anywhere from 1 to inf?
!solved