Tuesday 25 December 2012

C/C++ Puzzles: PART - 7


Printing "Hello World" Without using Semi Colon

  How to write a C/C++ program which prints the message "Hello World" on the screen, which does not contain a semi colon. So you should write a program without a single semi colon.

//Solution 1
#include<stdio.h>
int main()
{
  if(printf("\nHello World!!!\n"))
  {
  }
}


//Solution 2
#include<stdio.h>
int main(int argc, char *argv[printf("\nHello World!!!\n")])
{
}

Download

//Solution 3
#include <stdio.h>
int main(void *Hello[printf("\nHello world!!!\n")]) {}

Download 

There might be other solutions. If you come across any such solution please post a comment.


No comments:

Post a Comment