NESTED FUNCTIONS - C-Tutorial

Latest

Friday, 11 November 2016

NESTED FUNCTIONS


NESTED FUNCTIONS

Functions can also be placed within another function.  Such representation is known as nested functions.

Syntax: main() Fun1() Fun2()
{ { {
  --   - -    - -
  --   Fun2();    - -
  Fun1();   - - }
  - - }
}

/* EXAMPLE PROGRAM FOR NESTED FUNCTIONS */

#include<stdio.h>
#include<conio.h>

void fun1();
void fun2();

main()
{
clrscr();
printf("\n main function starts");
fun1();
printf("\n main function ends");
}
void fun1()
{
printf("\n function1 starts");
fun2();
printf("\n  function1 ends");
}
void fun2()
{
printf("\n function2 starts");
printf("\n function2 ends");
}

No comments:

Post a Comment