CrazyEngineers Archive
Old, but evergreen and popular discussions on CrazyEngineers, presented to you in read-only mode.
@hare singh nayak • 21 Sep, 2012



please give the complete detailed solution of this program ..

#include 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); } }

@Vishal Sharma • 21 Sep, 2012 please present your code properly!
The way you have presented it, makes the question more complicated

https://www.crazyengineers.com/community/threads/tips-for-c-programmers-read-learn.58709/

See the 5th point in above link!
@clZazy • 22 Sep, 2012 I think the output should be --> 1213121
but I don't know why you declared "proc" function which you haven't used and also the typedef in this code is useless.
@Jeffrey Arulraj • 22 Sep, 2012 lots of queries why such a waste of memory here
@hare singh nayak • 22 Sep, 2012
Vishal0203
please present your code properly!
The way you have presented it, makes the question more complicated

https://www.crazyengineers.com/community/threads/tips-for-c-programmers-read-learn.58709/

See the 5th point in above link!
#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);
}
}
@Vishal Sharma • 23 Sep, 2012
hare singh nayak
#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);
}
}
I don't see any use of writing the function proc as it is not defined anywhere in your program. no use of typedef too... I think, you dint post the entire program!
still the program, wont print anything, as it is under recursion, and finally the condition fails and the program doesn't print anything..
@hare singh nayak • 23 Sep, 2012 #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);
}

hello friend the o/p of this program is 0,1,2,0,

but can you explain me how .?
@grsalvi • 28 Sep, 2012
#include<stdio.h>
 
 
void fun(int);
 
int main()
 
{
 
int a=3;
fun(a);
return 0;
 
}
 
 
void fun(int n)
 
{
 
if(n > 0)
 
{
 
fun(--n);
 
printf("%d,", n);
 
fun(--n);
 
}
 
return;
 
}

This code is seriously scary.When everthing in function fun has been executed.Instead of execution of return(bafck to main) the fun is called again...😕..well working out👍
@shameel24 • 01 Feb, 2016 • 1 like instead of solving above problem,solve this.. :/ i have removed every wasteless things and the o/p is 0 1 2 0. 😔 .. so pls do explain the logic

#include<stdio.h>
void fun(int);
int main()
{
fun(3);
}
if(n > 0)
{
fun(--n);
printf("%d ", n);
fun(--n);
}
}
3.3k views

Related Posts

@MECH Design · Apr 12, 2009

i Want to design a centrifugal blower's radial impeller for 10000 cfm output at 200 mm water column pressure. i want to know the calculation for the output in relation...
7.6k views

@Ankita Katdare · Oct 19, 2011

Download the Free Online Mock Aptitude Test Question PDFs here:
5.6k views

@Ruchika Bains · Mar 14, 2016

Project Abstract / Summary : The Idea of Sharing Battery power in Mobile phones just like Easy-Going Bluetooth modules is novice and not widely implemented. Here we Provide with a...
3.3k views

@Ambarish Ganesh · Jan 7, 2014

Micromax dual-boot Android/Windows 8.1 Tablet LapTab was revealed at CES 2014, and the Intel-powered tablet has dual operating systems- Windows 8.1 and Android. The official launch of this tablet is...
3k views

@Ankita Katdare · Nov 6, 2010

Following are the repeatedly asked Questions: Explain the different computer network functions. What are the differences between packet switching and circuit switching? Explain the OSI reference model with diagram. Compare...
5.8k views