search
Login

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

0 votes
35 views
asked Guru 24.6k points 29 51 75

1 Answer

0 votes
In C, program execution starts from the main() function. Every C program must contain a main() function. The main function may contain any number of statements. These statements are executed sequentially in the  order which they are written.

The main function can in-turn call other functions. When main calls a function, it passes the execution control to that function. The function returns control to main when a return statement is executed or when end of  function is reached. In C, the function prototype of the 'main' is one of the following:

int main(); //main with no arguments

int main(int argc, char *argv[]); //main with arguments

The parameters argc and argv respectively give the number and value of the program's command-linearguments.

Example:

#include <stdio.h>

/* program section begins here */

int main() {

// opening brace - program execution starts here

printf("Welcome to the world of C");

return 0;

}/

/ closing brace - program terminates here

Output:

Welcome to the world of C
answered Guru 39.1k points 10 21 31

Related questions

0 votes
1 answer 49 views
49 views
asked sara Guru 24.6k points 29 51 75
0 votes
1 answer 3.8K views
3.8K views
asked pax Sr Member 3.2k points 6 13 26
0 votes
1 answer 53 views
53 views
asked john Guru 27.1k points 31 47 92
1 vote
1 answer 104 views
104 views
what is command line arguments of main function?
asked steve Sr Member 1.5k points 8 23 36
0 votes
1 answer 24 views
...