how to execute with out main in cprogram
Answers were Sorted based on User's Feedback
#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 |
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 |
Answer / rupesh
#include<stdio.h>
#define hello main
void hello()
{
printf(" HIIIII ");
}
Is This Answer Correct ? | 3 Yes | 0 No |
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 |
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 |
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 |
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 |
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 |
Explain how do you determine a file’s attributes?
What is the difference between declaring a variable by constant keyword and #define ing that variable?
what is a NULL Pointer? Whether it is same as an uninitialized pointer?
Write a program using two-dimensional array that lists the odd numbers and even numbers separately in a 12 input values.
What is structure in c definition?
What is array of pointers to string?
Explain the concept and use of type void.
what is a non volatile key word in c language?
If we have an array of Interger values, find out a sub array which has a maximum value of the array and start and end positions of the array..The sub array must be contiguious. Take the start add to be 4000. For Ex if we have an array arr[] = {-1,-2,-5,9,4,3,-6,8,7,6,5,-3} here the sub array of max would be {8,7,6,5} coz the sum of max contiguous array is 8+7+6+5 = 26.The start and end position is 4014(8) and 4020(5).
5 Answers Microsoft, Motorola,
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
Find the highest of three numbers and print them using ascending orders?
Can we include one C program into another C program if yes how?