+ 14

How to write a Hello World program without main method?

Any type of functions to use instead of main?

11th Jul 2017, 12:29 PM
Bharath kumar
Bharath kumar - avatar
16 Respostas
+ 44
Try this (C++). #include <iostream> #define hello ma##in using namespace std; class HelloWorld { public: HelloWorld() { cout << "Hello World!"; } }world; int hello() { return 0; }
12th Jul 2017, 2:26 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 8
thank you for your Explanation
14th Jul 2017, 10:48 AM
Bharath kumar
Bharath kumar - avatar
+ 7
But can u alias the main method?
11th Jul 2017, 12:45 PM
Bharath kumar
Bharath kumar - avatar
+ 7
Open notepad and type Hello World. Save it. Now when you want to run the program, just click on the document and it'll tell you Hello World. However, I have to let you know, that's just an illusion because notepad has a main method, just like any other program I've seen.
11th Jul 2017, 1:07 PM
AgentSmith
+ 4
Without a main method the program wouldn't know where to start.
11th Jul 2017, 12:42 PM
Boris Batinkov
Boris Batinkov - avatar
+ 2
Maybe I didn't understand your point, but you can write it in an interpreted language. Python: Write file 'Hello_World.py' with content: print("Hello World")
11th Jul 2017, 1:19 PM
Boris Batinkov
Boris Batinkov - avatar
0
It's useful to know what main is. it's just a calling convention used by several programming languages to provide a label that can be used to indicate an entry point for a program that gets inserted into memory and executed. There are other ways to jump to addresses for execution as well. For example, if you look at software for a microcontroller, you'll find a vector table which likely starts at address 0 and goes up a few hundred bytes, arranged in small blocks that each jump to another point in memory. The purpose of this table is to respond when interrupts are triggered. So I can write a small program that sends "hello world" to a serial device or something that is triggered by a button push. I don't need a main function, but I do need to write the vector table into memory and run the processor from the reset vector. The vector table is almost guaranteed to be written in assembler specific to the processor. Once the processor has code to start up, I'd switch to C unless I had a very good reason. Once I'm in C, I'll almost always start with main.
14th Jul 2017, 9:49 AM
Greg Bodnar
Greg Bodnar - avatar
0
. VBS
14th Jul 2017, 12:35 PM
josh mizzi
josh mizzi - avatar
0
using php you can print hello world just using echo "hello world";
14th Jul 2017, 1:24 PM
SOURAV KUMAR
SOURAV KUMAR - avatar
- 1
FOR JAVA IF JDK Version is less than 5, then class TestClass { static { System.out.println("hello world"); } } if JDK version is greater than 6 - class TestClass { static { System.out.println("hello world"); } public static void main(String... s) { } }
13th Jul 2017, 10:33 AM
Dipesh Yadav
Dipesh Yadav - avatar
- 1
you need python ....
13th Jul 2017, 5:46 PM
suria sarath
suria sarath - avatar
- 1
what for?
14th Jul 2017, 5:31 AM
DNABIRONG
DNABIRONG - avatar
- 1
In Python, just type print("hello world"). The output will be ' hello world'
14th Jul 2017, 12:30 PM
Amos Robert
Amos Robert - avatar
- 2
Use static key word if you're coding in Java then call the non-main method in using the class name with the dot operator, e. g ClassName.methodName()
13th Jul 2017, 2:18 PM
Walter Adhao
Walter Adhao - avatar
- 2
Use any programming language that doesn't use a method named "main" as the executive part of the program.
13th Jul 2017, 5:49 PM
Paramkusham Venkata Vineeth Kumar
Paramkusham Venkata Vineeth Kumar - avatar
- 4
main is not really a function type it's a function name , u don't have to use any function u can directly cout<<"hello world";
14th Jul 2017, 10:54 AM
Anand Pandey
Anand Pandey - avatar