Knowledge Walls
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
Introduction [cont'd]
Input Output Functions [cont'd]
Structures and Unions [cont'd]
# Preprocessor [cont'd]
Nesting Functions in User-defined Functions of Programming in C
2186 Views
Nesting Functions 
A function calling different functions inside, It is called as Nesting functions.
Program
	#include
	//Nesting of functions
	//calling function inside another function
	//calling fact inside print_fact_table function
	void print_fact_table(int);
	int fact(int);
	void main(){
	   print_fact_table(5);
	}
	void print_fact_table(int n){
	   int i;
	   for (i=1;i<=n;i++)
	   printf("%d factorial is %d\n",i,fact(i));
	}
	int fact(int n){
	   if (n == 1)
	   return 1;
	   else
	   return n * fact(n-1);
	}
Output 
1 factorial is 1
2 factorial is 2
3 factorial is 6
4 factorial is 24
5 factorial is 120
Next Topics
Next lessons of current book.
User-defined Functions of Programming in C
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Previous Topics
Previous lessons of current book.
User-defined Functions of Programming in C
User-defined Functions of Programming in C
User-defined Functions of Programming in C
User-defined Functions of Programming in C
Best Lessons of "Programming in C"
Top lessons which are viewed more times.
Structures and Unions of Programming in C
Input Output Functions of Programming in C
Structures and Unions of Programming in C
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details