Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: OT: Pythonesque C

by AnomalousMonk (Archbishop)
on Sep 14, 2015 at 19:15 UTC ( [id://1141964]=note: print w/replies, xml ) Need Help??


in reply to Re: Help with While Loop
in thread Help with While Loop

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:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1141964]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-23 11:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found