Nesting of function call in C programming


Nesting of function call in c programming

If we are calling any function inside another function call is known as nesting function call. Sometime it converts a difficult program in easy one.
For example:
Try to find out maximum number among the five different integers without using nested function call.

Find the maximum number among five different integers using nested function call:

int max(int x,int y){return x>y?x:y;}
void main(){
    int m;
    m=max(max(4,max(11,6)),max(10,5));
    printf("%d",m);
    getch();
}

Output: 11  

2 comments:

Anonymous said...

it is recursion not nesting of function.

Zach Farmer said...

No, recursion would be calling max() from within max(). This is not what he is doing here; this is a nested function call.