C Programming - Functions - Discussion

Discussion Forum : Functions - Find Output of Program (Q.No. 5)
5.
What will be the output of the program?
#include<stdio.h>
void fun(int);
typedef int (*pf) (int, int);
int proc(pf, int, int);

int main()
{
    int a=3;
    fun(a);
    return 0;
}
void fun(int n)
{
    if(n > 0)
    {
        fun(--n);
        printf("%d,", n);
        fun(--n);
    }
}
0, 2, 1, 0,
1, 1, 2, 0,
0, 1, 0, 2,
0, 1, 2, 0,
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
96 comments Page 9 of 10.

Lakshay said:   9 years ago
The answer should be 0,1,2,1.

VInith kumar said:   7 years ago
Simply great @Mukunda Saini.

Shanmugapriya said:   1 decade ago
Please explain it in clear.

Sony said:   1 decade ago
Please explain it clearly.

Sumit Pankaj said:   1 decade ago
Please explain once more

Vidya said:   8 years ago
Well said @Sree. Thanks.

Bagesh kumar bagi said:   1 decade ago
Any one explain again?

Subu said:   1 decade ago
Please explain this.

Xyz said:   1 decade ago
Thanx aparajita !!!

BhavadipGothadiyaBG said:   8 years ago
How it's Possible?


Post your comments here:

Your comments will be displayed after verification.