Currently reading into PETSc when I came up to this syntax in C/C++:
PetscInt i, n = 10, col, its;
PetscScalar neg_one = -1.0, one = 1.0, value;
That's just declaring multiple variables of the same types.
int a, b;
The first line declares four variables of the type
n (which is initialized to
10), the array
col and finally
its. The second line declares three variables of the type
PetscInt i,n = 10,col,its;
is the same as:
PetscInt i; PetscInt n = 10; PetscInt col; PetscInt its;
Some find the original way shorter, easier to type, and also nice since it shows that the variables share (part of) the same type. Some find it confusing and/or error-prone, this is subjective of course but I felt I should mention it to kind of motivate why you often find code like this.