Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

C Program to print "hello world" without semicolon - Programming Puzzles

#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 puts(const char *str) {


fputs("Hello, world!\n", stdout);
}

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;
}

You might also like