2 ms·
Here is a version with 0 if statements #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { return printf(atoi(argv[1])
by charcircuit 3y ago
Here is a version with 0 if statements
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
return printf(atoi(argv[1]) & 1 ? "odd" : "even") < 0;
}
- brokensegue 3y agoStill branches
- chrismorgan 3y ago#include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { return printf(&"even\0odd"[(atoi(argv[1]) & 1) * 5]) < 0; }
- charcircuit 3y agoNot always. Popular architectures like x86_64 and ARM have instructions for conditional moves. These instructions do not cause the processor to branch.