fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int sum = 0;
  6. int k;
  7.  
  8. for (k = 1; ; k++) {
  9. sum += k;
  10. printf("k=%d sum=%d\n", k, sum);
  11. if (1000 < sum) {
  12. break;
  13. }
  14. }
  15. printf("k=%d\n", k);
  16.  
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
k=1 sum=1
k=2 sum=3
k=3 sum=6
k=4 sum=10
k=5 sum=15
k=6 sum=21
k=7 sum=28
k=8 sum=36
k=9 sum=45
k=10 sum=55
k=11 sum=66
k=12 sum=78
k=13 sum=91
k=14 sum=105
k=15 sum=120
k=16 sum=136
k=17 sum=153
k=18 sum=171
k=19 sum=190
k=20 sum=210
k=21 sum=231
k=22 sum=253
k=23 sum=276
k=24 sum=300
k=25 sum=325
k=26 sum=351
k=27 sum=378
k=28 sum=406
k=29 sum=435
k=30 sum=465
k=31 sum=496
k=32 sum=528
k=33 sum=561
k=34 sum=595
k=35 sum=630
k=36 sum=666
k=37 sum=703
k=38 sum=741
k=39 sum=780
k=40 sum=820
k=41 sum=861
k=42 sum=903
k=43 sum=946
k=44 sum=990
k=45 sum=1035
k=45