Professional Documents
Culture Documents
C Puzzels
C Puzzels
#include<stdio.h>
void main(){
if(printf("hello world")){}
}
#include<stdio.h>
void main(){
switch(printf("hello world")){}
}
#include<stdio.h>
void main(){
while(!printf("hello world")){}
}
-----------------------------------------------------------------------------------
---------------------------------------
These example may be work with gcc compiler only. If you are new to gcc,
please checkout https://developerinsider.co/compile-c-program-with-gcc-compiler-
on-bash-on-ubuntu-on-windows-10/
1. When compiled with GCC, the compiler replaces printf("Goodbye!\n") with
puts("Goodbye!"),
which is simpler and is supposed to be equivalent. I've sneakily provided my custom
puts function, so that gets called instead.
#include <stdio.h>
int main() {
printf("Goodbye!\n");
}
-----------------------------------------------------------------------------------
----------------------------------------------
sing happy birthday
#include<stdio.h>
int main()
{
for(int c;c-5;)
printf("Happy Birthday %s\n",++c-4?"To You":"Dear C");
return 0;
}