Question #265936

Write a fruitful function sum_to(n) that returns the sum of all integer numbers up to and

including n. So sum_to(10) would be 1+2+3. . . +10 which would return the value 55.


Expert's answer

into sum=0;
int sum_to(n){
for(int i=1;i=<n;i++){
sum=sum+i;
}
return sum;
} 
LATEST TUTORIALS
APPROVED BY CLIENTS