+ 1
Increment the value of a variable that starts with an initial value 1 and stops when the value becomes 5.
Write an algorithm and then code in C.
1 Odpowiedź
+ 1
void main () {
int ix;
for (ix = 1; ix <=5; ix++)
;
}
The for-loop is an empty loop that will break when the value becomes 5.
if you were to add the sleep() and kbhit() calls, it would make a nice wait function:
void wait () {
int ix = 1;
do {
sleep (1);
} while (!kbhit() && ++ix <=5 );
}
-------------------
cheers!