Comma operator C

Comma operator is used in for statement. If we want to initialize two or more related indices at the same time and if we want to increment or decrement more than one variable, we can use the comma operator in for loop.

for (expression1a, expression1b ; expression 2; expression 3)

Here expression1a and expression 1b are two expressions separated by comma operator. They will initialize two separate indices.

for (expression1; expression2; expression 3a, expression 3b)

Here expression3a and expression 3b are separated by comma operator. They are used to alter two different indices used simultaneously within the loop.

Only one expression is allowed in the test expression.

E.g.

for (j = 0, k = 3; j < k ; j = j + 2, k++)
{
}

Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

C Topics