summaryrefslogtreecommitdiff
path: root/test/regression/for1.c
blob: 4563ddea390120384bbe8b5430c100b63801dec8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* C99 'for' loops with declarations */

#include <stdio.h>

int main()
{
  int i;
  for (i = 0; i < 3; i++) printf("loop1: %d\n", i);
  for (int i = 0; i < 3; i++) printf("loop2: %d\n", i);
  printf("old i = %d\n", i);
  for (int i = 0, j; i < 3; i++) {
    j = i * 2 + 1; printf("loop3: %d %d\n", i, j);
  }
  printf("old i = %d\n", i);
  for (int i = 0, j = i + 4; i < 3; i++, j--) {
    printf("loop4: %d %d\n", i, j);
  }
  printf("old i = %d\n", i);
  return 0;
}