fork download
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. int i;
  6. float sum = 0;
  7. int n = 0;
  8.  
  9. for (i = 1; i <=10; i = i + 1)
  10. {
  11. sum = sum + i * i;
  12. n = n + 1;
  13. }
  14.  
  15. std::cout << "the average is " << sum/n << std::endl;
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
the average is 38.5