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);
}
}
Discussion:
96 comments Page 5 of 10.
Vishal said:
1 decade ago
Friends if we change the (--n) to (n--) after the printf statement
Then check the answer and explain it plz..........
Then check the answer and explain it plz..........
Shaheen Khan said:
8 years ago
I understood till 0 gets printed someone please explain after printing of 0 where does the call goes and how it works?
Nikunj said:
1 decade ago
Really good efforts.
I understood the concept of stack but please expand it more for better understanding!
I understood the concept of stack but please expand it more for better understanding!
Divyasree said:
1 decade ago
Its very confusing Rithesh. I can't able to undstand the flow of excecution. Can anyone explain it clearly?
Anu said:
1 decade ago
I too think sree is right... but yes.. we need a more elaborate explanation... pls...
Pavithra said:
1 decade ago
There is not return statement of any kind so I think this whole code won't execute.
Khan said:
8 years ago
When 0>0 the if statement fails then how the statements inside it will execute?
Naresh said:
8 years ago
I am not getting what happens after f (0). How will the output be 0 1 2 0?
Harish Mahajan said:
7 years ago
How can I recognize a function is a recursion?
Please explain me.
Please explain me.
(1)
Lakshmi said:
1 decade ago
Sree i didnt get wat u r saying.Plz can u explain me in brief.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers