Post increment in a loop
I am reading about what happens when a post increment is present in a loop and I came across this.Can anyone explain me the below code?
A simple loop like
i = 0;
while (a[i++] != 0)
{
...
}
has to be executed as
loop:
temp = i; /* save the value of the operand */
i = temp + 1; /* increment the operand */
if (a[temp] == 0) /* use the saved value */
goto no_loop;
...
goto loop;
no_loop:
or
loop:
temp = a; /* use the value of the operand */
i = i + 1; /* increment the operand */
if (temp == 0)
goto no_loop;
...
goto loop;
no_loop:
A simple loop like
i = 0;
while (a[i++] != 0)
{
...
}
has to be executed as
loop:
temp = i; /* save the value of the operand */
i = temp + 1; /* increment the operand */
if (a[temp] == 0) /* use the saved value */
goto no_loop;
...
goto loop;
no_loop:
or
loop:
temp = a; /* use the value of the operand */
i = i + 1; /* increment the operand */
if (temp == 0)
goto no_loop;
...
goto loop;
no_loop:
Replies
-
Anoop KumarPost increment mean calculate the value and then increament.
This will be
loop:
temp = i; /* save the value of the operand */
i = temp + 1; /* increment the operand */
if (a[temp] == 0) /* use the saved value */
i = temp + 1; /* post increament */
goto no_loop;
You are reading an archived discussion.
Related Posts
Does any have MRF Tyres placement papers for Elecctrical Engg??? I am gonna attend it so that i can have some idea to clear the technical online test.
I tried to buy any app for android but the transaction declines.
Does it requires any type of international bank account? (i tried SBI debit card)
need help !!😔
WHAT A CAR !
Correction, WHAT A POLICE CAR !!!
Ford had shown a marvel for the Police department. This has an inbuilt Laptop (like device); communication device, Flood lights,...
Hello all,
For those of you knowlegeable about this standard :
I don't quite get the notion of "hardware module" : the standard says that the partitions are run on...
Have courage to solve?
If you can, let's see how much time did you take to resolve this.
2+3=8,
3+7=27,
4+5=32,
5+8=60,
6+7=72,
7+8=??
Solve it?