What are functions ?
Functions are set of instructions combined in one placefor example we have been working with function main
void main()
{
}
like this we can create different kind of functions to make our code easy to understand, and we can call function as many times as required
Example:
#include<stdio.h>
#include<conio.h>
void testing(); /*function prototype declaration*/
void main()
{
printf("we are in main body\n");
testing(); /*calling function*/
printf("welcome back to main function");
}
void testing() /*defination of your function*/
{
printf("you are now in testing, see how control flows");
}
How it works
1. Basically We first tell that void testing(); just like int a2. then in main function we write testing(); this calls the fuction testing and controls goes to void testing() and statements in get executed. and you are now in testing is displayed on screen
3.after this the control gets back to the main body and you get on display welcome back to main.