the given code can be simplified as the code below without changing its meaning and output.
#include <stdio.h>
/*void swap(int *x, int *y)
{
static int *temp;
temp = x;
x = y;
y = temp;
}*/
void printab()
{
static int i, a = -3, b = -6;
i = 0;
while (i <= 4)
{
//we have to increment i irrespective of the number being odd or even
if (i % 2 == 1) //if i is odd
{
i++; // i is incremented here when it is odd
continue;
}
i++; //i is incremented here when it is even
a = a + i;
b = b + i;
}
//we can remove the swap function since it only swaps the pointers to a,b and has no effect on a,b values themselves.
//swap(&a, &b);
printf("a = %d, b = %d\n", a, b);
}
int main()
{
printab();
printab();
return 0;
}