B
BobR
This is my own C++ code for finding the sum of an arithmetics
sequence,
#include <iostream.h>
void main () {
That's not C++. This is C++ <G> :
#include <iostream>
int main(){
using std::cout;
using std::cin;
using std::endl;
while( true ){
int n(0), result(0); // now 'result' IS cleared every loop
cout<<"enter n"<<endl;
cin>>n;
if( (n==-999) || (n==0) ){
break;
} // if(n)
// - put 'result' here -
// int result(0); // now 'result' IS cleared every loop
for( int i(1); i <= n; ++i){
result+=i;
} // for(i)
cout<<"result is"<<result<<endl;
} // while()~
return 0; // self documentation :-}