how to execute with out main in cprogram

Answers were Sorted based on User's Feedback



how to execute with out main in cprogram..

Answer / ravinder rawat

#include<stdio.h>
#define ravinder(z,g,c,f,x,y) z##c##y##x
#define rawat ravinder(m,b,a,j,n,i)

void rawat()
{ printf("MGM NOIDA");
getch();}

Is This Answer Correct ?    43 Yes 11 No

how to execute with out main in cprogram..

Answer / sushil kumar

Well Done !!!!!!!
I can give an explanation
When a c program is compiled the preprocessor process the code and replace the macros in the code
IN void rawat()
#define rawat ravinder(m,b,a,j,n,i) replaces rawat so code becomes
void ravinder(m,b,a,j,n,i)()
which calls the first macro to replace ravinder(m,b,a,j,n,i) by m##a##i##n i.e main
so now we have
void main()

that's why this code executes correctly
C always requires a main program to execute

Is This Answer Correct ?    23 Yes 1 No

how to execute with out main in cprogram..

Answer / rupesh

#include<stdio.h>
#define hello main

void hello()
{
printf(" HIIIII ");
}

Is This Answer Correct ?    3 Yes 0 No

how to execute with out main in cprogram..

Answer / sathish

Well done Ravinder. I appreciate your answer.

Is This Answer Correct ?    2 Yes 0 No

how to execute with out main in cprogram..

Answer / gaurav

At most websites i read that no c prg. can be without main
but this was surprising
i never thought it could be done with such twist
good one

Is This Answer Correct ?    2 Yes 2 No

how to execute with out main in cprogram..

Answer / mahender

with out main() program xecution not posible
bt compiling is posible
bcoz prog. starts on main fun only

Is This Answer Correct ?    0 Yes 0 No

how to execute with out main in cprogram..

Answer / himanshu

ans 13 is not totally right!
you see you have used main straight away.
you aren't supposed to use main any where in the code.

Is This Answer Correct ?    0 Yes 0 No

how to execute with out main in cprogram..

Answer / himanshu rajput

Sushil kumar is right.exactly this is being happened in that program.That program is also using main function by the reference of other name.so c program always requires main function and does'nt have any mean without main.
but we do'nt need to write clrscr() and getch() function to our program in latest compilers like as DEV-C++.

Is This Answer Correct ?    0 Yes 0 No

how to execute with out main in cprogram..

Answer / rishabh

dude how it worked!!!!!!!

Is This Answer Correct ?    1 Yes 2 No

how to execute with out main in cprogram..

Answer / guest

clever code , I dnt know macros much
how u managed to run it
pls explain...

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C Interview Questions

Can you please explain the difference between syntax vs logical error?

0 Answers  


In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.

0 Answers  


What is pragma in c?

0 Answers  


This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory

0 Answers  


Find the output? void main() {float a=2.0; printf("\nSize of a ::%d",sizeof(a)); printf("\nSize of 2.0 ::%d",sizeof(2.0));}

11 Answers   IBM, TCS,


Explain is it valid to address one element beyond the end of an array?

0 Answers  


What is an volatile variable?

15 Answers   HP,


write a program to swap two variables a=5 , b= 10 without using third variable

5 Answers  


Explain how are portions of a program disabled in demo versions?

0 Answers  


Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

0 Answers  


write a program to find a given no. is divisible by 3 or not without using any arthimetic operators?

3 Answers   Broadcom, TCS,


what is pointer?

4 Answers  


Categories