Thursday, May 2, 2019

Main() function in C

Main() function is the entry point of any C program. It is the point at which execution of program is started. When a C program is executed, the execution control goes directly to the main() function. Every C program have a main() function.

Syntax

 void main()
 {
  .........
  .........
 }
In above syntax;
  • void: is a keyword in C language, void means nothing, whenever we use void as a function return type then that function nothing return. here main() function no return any value.
  • In place of void we can also use int return type of main() function, at that time main() return integer type value.
  • main: is a name of function which is predefined function in C library.

Simple example of main()

Example

#include<stdio.h>

void main()
{
printf("This is main function");
}

Output

This is main function

No comments:

Post a Comment

Why learning C Programming is a must?

C is a procedural programming language. It was initially developed by Dennis Ritchie between 1969 and 1973. It was mainly developed as...