In the pythonesque code you posted...
Not only Pythonesque, but perhaps also a bit C-ockamamie. The following works, although you have to torture the code to get the syntax right (and the indentation is meaningless). And it still doesn't do anything.
#include <stdio.h>
void main () {
int x = 5;
int y = 6;
while (x != y)
if (x > y)
printf("guessed %d: high. ", x), printf("next guess %d \n
+", x = y);
else if (x < y)
printf("guessed %d: low. ", x), printf("next guess %d \n"
+, x = y+1);
else
printf("got it! \n");
printf("done guessing \n");
}
Output:
c:\@Work\GCC\PerlMonks\gavin100>a
guessed 5: low. next guess 7
guessed 7: high. next guess 6
done guessing
Update: Changed node title. This really is OT.
Give a man a fish: <%-{-{-{-<