Finding a minimum in C++ without an array?
If anyone can help me out, that would be great! I'm currently working on a program in C++ where I have to find the average of x scores declared by the user, with the lowest score drop. I'm not allowed to use arrays. I've got everything functioning just fine except for getting the lowest score. Please tell me any changes I need to make to my code: #include "stdafx.h" #include <iostream> double calcAverage(double, double); double findLowest(double, double); using namespace std; double tests, lowest; double score; double l; double sum = 0, count = 0; int x; int main() { double tests, average; cout << "How many tests will there be? "; cin >> tests; cout << "Enter "<<tests<<" scores:\n"; cin>>score; lowest = score; for (int x = 2; x <= tests; x++) { cin >> score; l = findLowest(score, lowest); sum+=score; count++; } sum -= lowest; cout<<"Lowest number is: "<<l<<endl; // cout<<"Sum is: "<<sum<<endl; double i = calcAverage(sum, count); cout<<"Average without the lowest score is: " << i <<endl; return 0; } double findLowest(double score, double lowest) { if(score < lowest) lowest = score; return score; } double calcAverage(double sum, double count) { double avg = sum / (count - 1); return avg; }