How to insert an "endl" at a certain place in my program?
Oct 16, 2012 at 1:07am UTC
I'm trying to figure out how to insert a new line at a certain place in my program. I'd like to have a line inserted after the last pledge is entered and before the display of the cout statement on
line 27 "The number of pledges that are $100 or above are"
Any help would be appreciated. :-)
Here's the code:
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
#include<iostream>
using namespace std;
int main ()
{
int numOfDonors = 0;
int pledge = 0;
int sumOfDonors = 0;
int donorsOverHundred = 0;
cout << "Enter the pledge amount and then press enter to continue [-1 to stop]..." << endl << endl;
while (pledge >= 0)
{
cout << "Donor " << (numOfDonors + 1) << ": " ;
cin >> pledge;
sumOfDonors = sumOfDonors + pledge;
numOfDonors = numOfDonors + 1;
if (pledge >= 100)
donorsOverHundred = donorsOverHundred + 1;
}
cout << "The number of pledges that are $100 or above are " << donorsOverHundred << "." << endl << endl;
system("pause" );
return 0;
}
Oct 16, 2012 at 1:37am UTC
Maybe I'm not understanding your question.
What's wrong with
line 26:
cout << endl;
Oct 16, 2012 at 1:52am UTC
Doh! Such a simple solution. My bad. Thank you for your input, AbstractionAnon. Time to get some much needed sleep...
Topic archived. No new replies allowed.