|
| ||||||||||
| Tags: c language, function, main |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Purpose : Main( ) Function in C
|
|
#2
| ||||
| ||||
| Purpose : Main( ) Function in C
The main( ) function invokes other functions that are within it. Main function is the first function that is to be called when the program starts it's execution. The following are the some key points : 1. Main function returns an int value to the environment that called the program. 2. Main function is the starting function of the any C program. 3. Main function is a user-defined function. 4. Recursive call can also be allowed for Main function. 5. When the closing braces of the Main function can be reached that time program execution come to an end. 6. Main function has two arguments : a)argument count; b) argument vector. 7. Instead of argv and argc, Any name that is defined by the user can also be used as parameters for Main function. |
|
#3
| ||||
| ||||
| Main( ) Function in C
Main function is a function that must be very essential in your program. It does not matters where you are writing your Main function in your program. Wherever you write a Main function in your program but still it will starts execution from main function. Your program can be compiled without Main function but to RUN your program you must need Main function. Main function behaves like a function and its by default datatype is int. Because of that you can not define a function inside Main function. Whenever your program starts it always first looks for the Main function and then it starts its execution from it. So, without Main function you can't able to RUN your program. |
|
#4
| ||||
| ||||
| Program : Main( ) Function in C
I think you should learn through the following code of lines : #<include stdio.h> #<include conio.h> void main() { int a, b,c; a = 5; b = 4; c = a + b printf(" The sum of a and b is = ",c); } The output of the code is The sum of a and b is = 9 |
|
#5
| ||||
| ||||
| Main( ) Function in
In your C language, every program that you have written starts with Main function because the Main function tells the C compiler from where the program starts its execution. There is one more example : #<include stdio.h> #<include conio.h> void main() { int p, q, r; p = 5; q = 4; r = a % b; printf(" The mod of a and b is = ",c); } The output of the code is The sum of a and b is = 1 |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Purpose : Main( ) Function in C" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Main Menu of Blacklight Retribution is running to slow to function | Run.DK | Video Games | 6 | 03-04-2012 09:39 PM |
| Differences between int main() and int main(void) | BOGUMIL | Software Development | 5 | 10-06-2011 06:55 AM |
| How to call a function in the "main" function | MaryJ | Software Development | 1 | 19-11-2010 12:40 AM |
| If variable is not initialized in main function | Jaisudha | Software Development | 3 | 18-11-2009 01:13 PM |
| How to implement function like fetch_object and the purpose of using it? | Mahendra varma | Software Development | 3 | 05-09-2009 10:10 AM |