fork download
  1. #include<iostream>
  2.  
  3. int main()
  4. {
  5. int sum = 0, val = 10;
  6.  
  7.  
  8. while (val > 0)
  9. {
  10. std::cout << sum
  11. << "+"
  12. << val
  13. << "=";
  14.  
  15. sum += val;
  16.  
  17. std::cout << sum << "\n";
  18. --val;
  19. }
  20. std::cout << "Sum of 1 to 10 =" << sum << std::endl;
  21.  
  22. return 0;
  23.  
  24.  
  25. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
0+10=10
10+9=19
19+8=27
27+7=34
34+6=40
40+5=45
45+4=49
49+3=52
52+2=54
54+1=55
Sum of 1 to 10 =55