Skip to content

Instantly share code, notes, and snippets.

@phaya

phaya/ifless.c Secret

Last active December 25, 2015 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phaya/5e5184e01cce75473600 to your computer and use it in GitHub Desktop.
Save phaya/5e5184e01cce75473600 to your computer and use it in GitHub Desktop.
"1 < 15 < 10" algo realmente raro está pasando aquí ¿alguna idea?
#include <stdio.h>
int main() {
int n = 15;
if (1 < n < 10) {
printf("1 < %d < 10\n", n);
}
return 0;
}
@javierdarna
Copy link

Lo que pasa es que en la condicion el compilador lee primero 1<n, que es cierto y por ello retorna 1. luego lee 1<10 que tambien es cierto, por lo que la condicion es cierta

@phaya
Copy link
Author

phaya commented Oct 18, 2013

¡Tocado y hundido!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment