wap to print "hello world" without using the main function.

Answers were Sorted based on User's Feedback



wap to print "hello world" without using the main function...

Answer / kk

Here is a basic sample which uses main as the entry point..
#include <stdio.h>
#define myProxyMain main

int myProxyMain()
{
printf("\nHello World !!");
getchar();
return 0;
}

Just note that at source level there is no main but once
preprocessing we still have the old main() method.. Which
means we still have the main method in the object module as
well as the executable..

Is This Answer Correct ?    37 Yes 11 No

wap to print "hello world" without using the main function...

Answer / nitish_bhasin

#include<stdio.h>
#define nitish main
void nitish()
{
printf("Hello World");
}

Is This Answer Correct ?    40 Yes 20 No

wap to print "hello world" without using the main function...

Answer / smarty coder

Use pragma directive if you want to do something before
executing main function..

Is This Answer Correct ?    14 Yes 1 No

wap to print "hello world" without using the main function...

Answer / manne ranjith

Using Macros we can solve this.

#include<stdio.h>
#include<conio.h>

#define manne main

void manne()
{
clrscr();
printf("HELLO WORLD\n");
getch();
}

Is This Answer Correct ?    27 Yes 18 No

wap to print "hello world" without using the main function...

Answer / niranjan vg

compile the above file using the following command

# gcc -nostartfiles <filename.c>

# ./a.out

Is This Answer Correct ?    10 Yes 2 No

wap to print "hello world" without using the main function...

Answer / deepika

#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");
}

Is This Answer Correct ?    7 Yes 2 No

wap to print "hello world" without using the main function...

Answer / hemanthkumar

#include<stdio.h>
#define hemanth main
public hemanth()
{
printf("hello world");
}

Is This Answer Correct ?    5 Yes 1 No

wap to print "hello world" without using the main function...

Answer / uttam kumar das

#include<stdio.h>
#include<conio.h>
#define uttam main
uttam()
{
printf("hello world");
getch();
return 0;
}

Is This Answer Correct ?    8 Yes 6 No

wap to print "hello world" without using the main function...

Answer / niranjan vg

This is the other way you can use it.....

#include<stdio.h>


int hello();



_start()
{
_exit(hello());
}



int hello()
{
printf("\n \t\t\t\t\tHello World\n");
printf("\n \t \t \t Welome to C in Linux\n");
}

Is This Answer Correct ?    6 Yes 6 No

wap to print "hello world" without using the main function...

Answer / andy

Ranjan's answer was the correct one. And it's what interviewers expect.

use g++ to compile and run this:

#include<stdio.h>
#include<iostream>

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

World w1;

int main()
{
printf("Hello world again!!\n");
return 0;
}

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

What are the types of type specifiers?

0 Answers  


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

0 Answers  


#include<stdio.h> int main() { int a[3][3][2]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18}; printf("%d\n",*(*(*a+1)); return 0; } What will be the output of the above question? And how?

1 Answers   Groupon,


What are the application of void data type in c?

0 Answers  


please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

0 Answers  






What does c in a circle mean?

0 Answers  


What is the difference between procedural and functional programming?

0 Answers  


Write a program to compute the following 1!+2!+...n!

4 Answers  


Is both getch() and getchar() functions are similar? if it is similar means why these two functions are used for same usage? if it is not similar means what is the difference?

1 Answers   Infosys,


In header files whether functions are declared or defined?

1 Answers   TCS,


What is the explanation for the dangling pointer in c?

0 Answers  


What is the use of #define preprocessor in c?

0 Answers  


Categories