+ 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.

11th Feb 2017, 3:58 PM
Sunny Jha
Sunny Jha - avatar
1 Answer
+ 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!
11th Feb 2017, 4:08 PM
Mike L.
Mike L. - avatar