- #1
magnifik
- 360
- 0
i know this is a super easy program, but for some reason it's not working the way i want it to
Code:
// prompt user to enter several GPA's then find the average
// while the user's input is not the sentinel value, -1, add it to the sum
#include <iostream>
using namespace std;
int main(){
double GPA = 0;
double sum = 0;
double count = 0;
double average = sum / count;
while (GPA != -1){
cin >> GPA;
sum += GPA;
if (GPA != 1){
count++;
}
}
cout << average;
return 0;
}