[SOLVED] Can we define 2 counters of different types in a single for loop statement in C and increase them?


Can we use for statement like that? (C programming language)

for(int i = 0,double j = 2; i != j+134; i++, j = j+17);

I’m trying to learn linked list and I try to increase the index and set the pointer to next node just by using a single for:

for(node* current,int i = 0; current!=NULL; current=current->next_node, i++);


What about?

struct IntDouble { int i; double j; };
for (struct IntDouble q = {0, 2}; q.i != q.j + 134; q.i++, q.j += 17) /* void */;

See code "running" at https://ideone.com/jEXBh7

Answered By – pmg

Answer Checked By – Jay B. (BugsFixing Admin)

Leave a Reply

Your email address will not be published.