Wednesday, August 17, 2011

Interview Questions: wap to print "hello world" without reaching the main function in C++

There are several ways to do this:

1.
#include<stdio.h>
#include<conio.h>
#define uttam main
uttam()
{
printf("hello world");
getch();
return 0;
}
 
2. 
#include<stdio.h>
#define(s,t,u,m,p,e,d)m##s##u##t
#define begin decode(a,n,i,m,a,t,e)
int begin()
{
printf("Hello World");
}
 
3.
#include<stdio.h>
#include<iostream>

class World
{
 public:
 World()
 {
  printf("Hello world\n");
 }
};

World w1;

int main()
{
	printf("Hello world again!!\n");
	return 0;
}
 
source, click here.   

No comments:

Post a Comment