wap to print "hello world" without using the main function.
Answers were Sorted based on User's Feedback
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 |
Answer / nitish_bhasin
#include<stdio.h>
#define nitish main
void nitish()
{
printf("Hello World");
}
Is This Answer Correct ? | 40 Yes | 20 No |
Answer / smarty coder
Use pragma directive if you want to do something before
executing main function..
Is This Answer Correct ? | 14 Yes | 1 No |
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 |
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 |
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 |
Answer / hemanthkumar
#include<stdio.h>
#define hemanth main
public hemanth()
{
printf("hello world");
}
Is This Answer Correct ? | 5 Yes | 1 No |
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 |
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 |
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 |
wap in c to accept a number display the total count of digit
What will be result of the following program? void myalloc(char *x, int n) { x= (char *)malloc(n*sizeof(char)); memset(x,\0,n*sizeof(char)); } main() { char *g="String"; myalloc(g,20); strcpy(g,"Oldstring"); printf("The string is %s",g); } a) The string is : String b) Run time error/Core dump c) The string is : Oldstring d) Syntax error during compilation e) None of these
What is merge sort in c?
why you will give me a job in TCS.
What is substring in c?
find largest element in array w/o using sorting techniques.
Why we use int main and void main?
Why is struct padding needed?
What is #define?
void main() { int a=1; printf("%d %d %d",a,++a,a++); } the output is supposed to be 1 2 2....but it is 3 3 1 this is due to calling conventions of C. if anyone can explain me how it happens?
You have given 2 array. You need to find whether they will create the same BST or not. For example: Array1:10 5 20 15 30 Array2:10 20 15 30 5 Result: True Array1:10 5 20 15 30 Array2:10 15 20 30 5 Result: False One Approach is Pretty Clear by creating BST O(nlogn) then checking two tree for identical O(N) overall O(nlogn) ..we need there exist O(N) Time & O(1) Space also without extra space .Algorithm ?? DevoCoder guest Posted 3 months ago # #define true 1 #define false 0 int check(int a1[],int a2[],int n1,int n2) { int i; //n1 size of array a1[] and n2 size of a2[] if(n1!=n2) return false; //n1 and n2 must be same for(i=0;i<n1-1;i++) { if( !( (a1[i]>a1[i+1]) && (a2[i]>a2[i+1]) ) ) return false; } return true;//assumed that each array doesn't contain duplicate elements in themshelves }
Explain the properties of union.