This program takes the name of the course, grade and the number of units of a course to calculate the grade point average. I want the program to exit the while loop after the user enters the letter q and display the phrase outside the loop.
#include <iostream>
using namespace std;
int main()
{
    char name[20];
    float unit;
    float score;
    float avg = 0;
    float total = 0;
    int q=0, c=0;
    
    while (name[20]!= q)
    {
        
            cout << "Enter a Name";
            cin >> name;
            cout << "Enter  score";
            cin >> score;
            cout << "Enter unit of surce";
            cin >> unit;
            avg = avg + score * unit;
            total = total + unit;
            cout << "cantinue(c) or break(q)";
            cin >> name[20];
        
        
    }
    avg = avg / total;
    cout << "gpa :" << " " << avg;
    return 0;
}
 
     
    