I got this question
Write a C++ program such that its execution will keep asking the user to enter a pair of integers, start and finish, and will terminate when either start>finish, or EOF or an invalid input has been encountered. Every time a new pair of integers start and finish are read, the program will first calculate the subtotal
start2 + (start+1)2 + (start+2)2 + ... + (finish-1)2 + finish2
and then add the subtotal to the total. Before the program terminates, it should display the accumulated total and the average of all the subtotals.
I managed to get the first and last number up but i seem to be stuck on the adding start2+ etc
#include <iostream>
using namespace std;
int main()
{
int firstNumber = 0;
int lastNumber = 0;
bool ValidInput = false;
do
{
cout << "Please enter first number: ";
cin >> firstNumber;
cout << "Please enter last number: ";
cin >> lastNumber;
}
else
{
int total;
total = firstNumber + lastNumber;
cout << "The Start Number Is : " << firstNumber << endl;
cout << "The Last Number Is: " << lastNumber << endl;
cout << "The subtotal is: " << total << endl;
}