Before the loop: add the variables int index and double value, set both to 0.
Within the loop: each iteration increase the index. Add the length to the value.
After the loop: if the index is greater 0 devide the value by that index
#include <iostream>
usingnamespace std;
int main(void){
int s,n;
int index = 0;
double value = 0;
do{
...
index++;
value += s;
...
}while(true);
if(index > 0)
cout << index << " squares printed. Average length: " << value / index << endl;
system("pause");
return 0;
}
I tried something but couldn't finish all codes. I had trouble with filling the bool function.. How can I fill in that Function, and also does that code logical??
The first thing is to convert to number to a string, then compare the first to last, second to second last, until you have no more elements or you have a middle element. Hope it makes sense :)