Tuesday, 22 March 2016

importance of main function ???

Hello guys, to I am gonna tell you guys about main function and will our program can be complied without main function….




Here our program…



#include<stdio.h>
#include<conio.h>
void main()
{
 clrscr();
 printf("hello world");
}




 Here in this program why there’s not a semi-colon after parenthesis ()?

Unlike clrscr() , we are basically defining a function named as main. Any name followed by parenthesis is a function in C language. We will discuss more about functions later on. so if we place a semicolon after function name with a parenthesis we basically calls a function .when we call a function it executes the codes or instruction which are written between curly brackets {}.


What if we don’t define main function?????

We can define function of any name like Hello() , program() etc. but what if we don’t define main function.
So if we don’t define main function the program will compile successfully, the only problem what we come across is that we can’t run our program. Our IDE of C language is only responsible for compiling our codes. Neither C language nor our IDE runs our program. Running a program is the job of your operating system. Operating system first searches for main function before executing our codes or instruction. So if we won’t define main function , our program will compile successfully but we won’t able to run our program as operating system will be unable to find main function.so there will be an runtime error.

Thank you!!!!! Happy holi !!!!

Related Posts:

  • printf("") Hello guys, today i am gonna tell you about the function known as printf(); here is our basic program we are gonna study all of its element li… Read More
  • BASIC C program hello guys , today we are gonna start with our 1st program in C language....we are gonna learn this program in small small parts cause this is yo… Read More
  • IDE.....!!!! HELLO  guys , today i am gonna show you guys how to install IDE  of C langugae... SO  guys what is an IDE ? well guys ,IDE stands … Read More
  • conio Hello guys, today i am gonna tell you about the header file which is <conio.h>.. here is our basic program we are gonna study all of … Read More
  • stdio.h????? hello guys, today i am gonna tell you about most used header file which is <stdio.h>.. here is our basic program we are gonna study all of… Read More

0 comments:

Post a Comment