I am using CodeBlocks to teach C++ at a community college. We are using Windows PCs with Windows 10 installed.
Recently I tried to run the following program in class:
#include <iostream>
#include <string>
using namespace std;
int main()
{
//int x;
string name;
double weight;
cout << "Enter the first and last name: ";
getline(cin, name);
cout << "Enter the weight: ";
cin >> weight;
if (weight >= 105.0 && weight <= 141.0) {
cout << name << " is in one of these weight classes: " << endl;
cout << "Featherweight, Flyweight" << endl;
cout << "Bantamweight, Lightweight" << endl;
}
else {
cout << name << " is in one of these weight classes: " << endl;
cout << "Light Welterweight, Welterweight, Middleweight, Light Heavyweight, Heavyweight" << endl;
}
return 0;
}
But when I ran the program, all the showed up in the console window was what you see in the attached file. I did not get the prompt and no output displayed. The code compiled with no errors.
The funny thing is, this program was working earlier until I put three or more cout's in either the if or the else. Also sometimes when I would compile successfully and the run the program, a dialog box would appear saying it appeared the program had not been built and asking if I would like to build it now.
This also happened to many students in my class. It was very frustrating to have this happen randomly and not know why.
Can anyone help me figure out why this happened? I hope I've given enough details on this...