Chapter 5 Quick Reference To Add an amount to a variable Subtract an amount from a variable Run one or more statements while a condition is true Repeatedly execute statements one or
Trang 1Chapter 5 Quick Reference
To
Add an amount to a variable
Subtract an amount from a variable
Run one or more statements while a
condition is true
Repeatedly execute statements one or
more times
Do this
Use the compound addition operator For example:
variable += amount;
Use the compound subtraction operator For example:
variable -= amount;
Use a while statement For example:
inti=0;
while G != 10)
{
Console WriteLine(i);
i++;
}
Alternatively, use a for statement For example:
for Gnt 1 = 0; 1 != 10; 1++)
{
Console WriteLine(i);
} Use a do statement For example:
inti=0;
do
{
Console WriteLine(i);
i++;
}
while G != 10);