answersLogoWhite

0


Best Answer

No, a program may not work with two main methods. If we preferred with working with many packages means then each package may consist of a main method.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: If a program have 2 main methods can the program run or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How to write java program without using main method?

Java program without mainWe need a main method for executing a program.But YES we can write a program without using main() method.TRICK 1 of 2 :: while writing applets in java we don't use main... we use init() method instead.TRICK 2 of 2 :: using 'static' we can write a program whic will execute successfully and output the desired message on screen. Here it is :: class Mohit{ static { System.out.println("This java program has run without the main method"); System.exit(0); } } -->save the program as Mohit.java to compile::javac Mohit.java (in command prompt) to run ::java Mohit(command prompt) output will be ::This java program has run without the main methodWhoa!!!!! we are done.;)


Can you have two mains in a c program?

No you can't. main() is the entry point of a C program where execution starts. Only a single main() can exist in a C program. A program with 2 mains wil not even compile successfully.


Where does the main function starts and end in c program?

The entry point of a C program is the main function.The function signature might be like one of these:1. int main (void)2. int main (int argc, char *argv[])


How do you merge 2 Visual C programs to get a single output?

You cannot. A C program can only have one global main function but you'd be trying to compile a program that has two main functions. The only way to merge the two programs is to modularise both programs so that neither is dependent upon their main functions. Once modularised, you can include those modules in any program. Alternatively, you can create binary libraries from the modules and link them into any program.


How do you run daemon process?

In Unix, with a C program you can run a quick function to do this. There is an example at:(link moved to link section)AnswerIn Solaris, you need to disconnect your program from your "terminal" ( scripts generally inherit the stdin, stdout, and stderr of your shell when you execute them ). For a shell program you can execute "nohup $program < /dev/null > /dev/null 2>&1 &". Or the shell program can redirect its own stdin, stdout, and stderr -- then you can execute "nohup $program &".

Related questions

How to write java program without using main method?

Java program without mainWe need a main method for executing a program.But YES we can write a program without using main() method.TRICK 1 of 2 :: while writing applets in java we don't use main... we use init() method instead.TRICK 2 of 2 :: using 'static' we can write a program whic will execute successfully and output the desired message on screen. Here it is :: class Mohit{ static { System.out.println("This java program has run without the main method"); System.exit(0); } } -->save the program as Mohit.java to compile::javac Mohit.java (in command prompt) to run ::java Mohit(command prompt) output will be ::This java program has run without the main methodWhoa!!!!! we are done.;)


What are the 2 main methods of reproduction?

Sexual and asexual reproduction.


Can you have two mains in a c program?

No you can't. main() is the entry point of a C program where execution starts. Only a single main() can exist in a C program. A program with 2 mains wil not even compile successfully.


Write a program adding 2 plus 2 in c program?

#include &lt;stdio.h&gt; int main (void) { puts ("4"); return 0; }


Can Mame work in PlayStation 2?

No. There currently isn't a emulator program that will run on an unmodified Playstation 2


What is the main setting of Heroes Don't Run?

in world war 2


Where does the main function starts and end in c program?

The entry point of a C program is the main function.The function signature might be like one of these:1. int main (void)2. int main (int argc, char *argv[])


What is important for choosing an operating system?

The main 2 questions you must ask yourself are; 1.Can my PC run it? 2.Can it run what want to use?


What Program structure for a C program?

1.Declaration of header files. 2.void main()/main() 3.delcaration of the variable. 4.Printf&amp;scanf statement. 5.execution. 6.result


Why is it better 2 use renewable energy?

Well, a main point is obvious, it's renewable. Fossil fuels, although abundant, have a limited supply; eventually they'll run out. Also, though all methods for harnessing energy have their own environmental effects, renewable energies tend to be less harmful than currently used methods.


Windows 2000 has 3 main install methods what are they?

1-upgrade 2-clean boot 3-dual boot


What are the two different kinds of errors which can be in a program?

1. compilation errors 2. run time errors