fork download
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int flag, sum, n;
  5.  
  6. flag = 1;
  7. sum = 0;
  8. for (n = 1; n <= 100; n++){
  9. sum += n * n;
  10. if (flag && sum >= 100) {
  11. printf("sumが初めて100以上になる n=%d\n", n);
  12. flag = 0;
  13. }
  14. }
  15. printf("総和=%d\n", sum);
  16. }
  17.  
Runtime error #stdin #stdout 0s 1788KB
stdin
Standard input is empty
stdout
sumが初めて100以上になる n=7
総和=338350