This was my solution
but i don't know how can i detect an overflow??
Code:
#include <iostream.h>
int main(){
int x;
int eof = 0;
int sum = 0;
cout<<"Enter a list of integers in the range of -100 to 100 (0 to end):"<<endl;
cin>>x;
try{
if(x<-100 || x>100)
throw x;
sum = x*x;}
catch(int e){
cout<<e<<" is out of range"<<endl;}
while(x != eof){
cin>>x;
try{
if(x<-100 || x>100)
throw x;
sum = sum+(x*x);}
catch(int e){
cout<<e<<" is out of range"<<endl;}
}
cout<<"sum of the input squares = "<<sum<<endl;
return 0;}