answersLogoWhite

0


Best Answer

int main (void)

or

int main(int a, char **p)

User Avatar

Wiki User

βˆ™ 14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How is main function declared?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the name of the function which must be defined in a Java program?

The main function. Every program must have a main function and it must be declared static.


Does a function call come before main?

It does not have to. What is necessary, is that a function be declared before using it, so you either need function declaration separately from definition, or you need to arrange the declaration/definition in the right order, which usually places the main() function last.


Can you declare a function in the body of another function in c language?

yes, we can not declare a function in the body of another function. but if we declare a function in the body of another function then we can call that very function only in that particular function in which it is declared; and that declared function is not known to other functions present in your programme. So if a function is required in almost all functions of your programme so you must declare it outside the main function i.e in the beginning of your programme.


How do you access global variable from within the main function when the local variable is of the same name?

When you acess a global variable inside main function you must use the same name, because the variable declared as global can be accessed by any function/procedure on the class where it was defined.


What is return means in programming?

A return statement exits the function in which it is declared and gives control to the calling code. Returning from the main function exits the program and gives control to the execution environment.

Related questions

What is the name of the function which must be defined in a Java program?

The main function. Every program must have a main function and it must be declared static.


What is the difference between return 0 and return -1 in c?

If we consider any function that is not the main function that is declared as "bool" i.e it will return boolean values to the main function-0 & 1, meaning 'false' and 'true' respectively. If we have to tell the main function that the condition checked in the function is false or disagreed, then we return 0 to the main function and when we have to tell that the condition checked in the main function is true or agreed, then we return 1 to the main function.


Does a function call come before main?

It does not have to. What is necessary, is that a function be declared before using it, so you either need function declaration separately from definition, or you need to arrange the declaration/definition in the right order, which usually places the main() function last.


Is global variables are declared within the main function?

Might be, but don't forget the keyword 'extern':int main (void){extern int errno;...}


Can you declare a function in the body of another function in c language?

yes, we can not declare a function in the body of another function. but if we declare a function in the body of another function then we can call that very function only in that particular function in which it is declared; and that declared function is not known to other functions present in your programme. So if a function is required in almost all functions of your programme so you must declare it outside the main function i.e in the beginning of your programme.


How do you access global variable from within the main function when the local variable is of the same name?

When you acess a global variable inside main function you must use the same name, because the variable declared as global can be accessed by any function/procedure on the class where it was defined.


What is a function statement?

A function statement is a block where the function is declared and defined.


What is return means in programming?

A return statement exits the function in which it is declared and gives control to the calling code. Returning from the main function exits the program and gives control to the execution environment.


Why all variables are declared with in the function?

It is not necessary to to declare variables inside the function in C. If you declare a variable inside a function, the variable becomes local for the function and another variable of same name can be declared in any other function, but you can not use the variable declared in other function. When you declare any variable outside the function body then the variable becomes global and can be used in any function of the program. Note: errno is an example for a variable declared outside any function.


When is a function executed and where should a function prototype and function definition appear in a source program?

If you want to use prototype it has to be declared before main(). If you have a function of type double with one argument of type int (with name arg), and the function name is func, then we have:#include ...double func(int arg);...int main(...){...return 0;}...double func(int arg){...}


What is functional statement?

A function statement is a block where the function is declared and defined.


Why should a function or a variable be declared before its first use?

It is somewhat syntax of programming. But when program runs,device known as pre-processor process statements before main function. So when we use that function inside main function it will get idea and run directly without showing any error. So for compilers simplicity and fast execution purpose it is necessary to declare function before its use.