I noticed that in one particular program I did for school
Code:
using namespace std;
int main()
{
float numOne, numTwo, numThree, numFour, numFive;
int convOne, convTwo, convThree, convFour, convFive; //represent decimals converted into integers
int sum; //represents sum of all integers
cout << "Follow the directions on the screen\n\n";
cout << "Please enter the first decimal number and press enter: ";
cin >> numOne;
cout << "\nPlease enter the second decimal number and press enter: ";
cin >> numTwo;
cout << "\nPlease enter the third decimal number and press enter: ";
cin >> numThree;
cout << "\nPlease enter the fourth decimal number and press enter: ";
cin >> numFour;
cout << "\nPlease enter the last decimal number and press enter: ";
cin >> numFive;
cout << "The numbers you entered were as follows:\n";
cout << "1:\t" << numOne << endl;
cout << "2:\t" << numTwo << endl;
cout << "3:\t" << numThree << endl;
cout << "4:\t" << numFour << endl;
line 23: cout << "5:\t" << numOne << "\n"; // endl would not allow further execution
cout << "Now rounding numbers to nearest integer........\n\n";
convOne = (int) (numOne + 0.5); //converting the decimals to
convTwo = (int) (numTwo + 0.5); //nearest integer
convThree = (int) (numThree + 0.5);
convFour = (int) (numFour + 0.5);
convFive = (int) (numFive + 0.5);
sum = convOne + convTwo + convThree + convFour + convFive; //adds the integers
cout << "The sum of these integers is: " << sum << endl;
cout << "The average of these integers is: " << sum / 5 << endl;
cin.ignore(10000, '\n'); //pauses program to keep
cin.get(); //from early execution
return 0;
the first time I made the prog, i had endl on line 23 instead of newline and efter it got to line 23 it would not continue. I changed it to "\n" just to see if there was a difference and the program continued as it was intended. I don't get it that much though, I use \n all of the time anyway.