Science Fair Projects Ideas - Main function (programming)

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Main function (programming)

In some programming languages, the main function is where a program starts execution.

It is the first user-written function run when a program starts (some system-specific software generally runs before the main function). The main function usually organizes at a high level the functionality of the rest of the program. The main function typically has access to the program's command-line arguments .

Contents

C and C++

In C and C++, the function prototype of the main function is:

int main(int argc, char **argv)

The parameters argc and argv respectively give the number and value of the program's command-line arguments. Some systems permit a third parameter envp, which gives access to the program's environment.

The name main is special; normally every C and C++ program must define precisely one function of that name.

Java

Java programs start executing at the main method, which has the following method heading :

public static void main(String[] args)

Command-line arguments are passed in args. As in C and C++, the name "main" is special. Java's main methods don't return anything.

Python

In Python a function called main doesn't have any special significance. However, it is common practice to organize a program's main functionality in a function called main and call it with code similar to the following:

def main():
    <main program>

if __name__ == "__main__":
    main()

When a Python program is executed directly (as opposed to being imported from another program), the special global variable __name__ has the value "__main__".

External link

Last updated: 05-07-2005 09:50:30
10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice