Write a program using sentinel loop that gets the unspecified number of student names and and then 3 exam scores of each students and calculates the average.
my code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string studentNames;
double total;
string sentinel="No";
cout<< "Enter the names or enter No to stop"<< endl;
do
{
You're very close. You actually are getting the student name each time, but the program is skipping over it because of a cin buffering issue. This happens when you mix getline with 'cin >>' commands.
To fix, throw a cin.sync(); before the getline call.
This effectively discards all characters remaining in input stream buffer cin until (and including) a newline '\n' character appears. If there is no newline character the whole buffer is cleared.