fork download
  1. #include <stdio.h>
  2.  
  3. int a = 0; // 1. グローバル変数aを初期値0で定義
  4.  
  5. void func(void) { // 2. func関数(4. 引数も戻り値もない)
  6. a++; // 呼び出されるたびにaをインクリメント
  7. }
  8.  
  9. int main(void) {
  10. int b = 5; // 3. ローカル変数bを初期値5で定義
  11.  
  12. // 5. b回だけfuncを呼び出す
  13. for(int i = 0; i < b; i++) {
  14. func();
  15. }
  16.  
  17. // 呼び出し後のaの値を表示
  18. printf("%d\n", a);
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
5