Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links


Purpose : Main( ) Function in C

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 27-01-2010
Member
 
Join Date: Jan 2010
Posts: 19
Purpose : Main( ) Function in C

Sponsored Links
Hello, I am working in the ABC company as programmer. We are working on the C language in the company. but I don't have the much knowledge about the C language. So, I have to know about the Main function of the C language. I also want to know what is the purpose of the Main() function and what is the reason behind it. So, If Anyone is there who has the answer of my query then reply me as soon as possible! I am waiting for your reply!!!

Reply With Quote
  #2  
Old 27-01-2010
absolute55's Avatar
Member
 
Join Date: Nov 2005
Posts: 1,321
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.
Reply With Quote
  #3  
Old 27-01-2010
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,278
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.
Reply With Quote
  #4  
Old 27-01-2010
kelfro's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,991
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
Reply With Quote
  #5  
Old 27-01-2010
Praetor's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,943
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 08:49 AM.