#include<stdio.h>
void fun(int);
int main()
{
int a;
a=3;
fun(a);
printf("\n");
return 0;
}
void fun(int i)
{
if(n>0)
{
fun(--n);
printf("%d",n);
fun(--n);
}
} the answer is 0 1 2 0..someone explain how the code is
executed..?
Answer / siva kumar
for example :
Here a is three(3).
calling fun(3) in main function.
FUN(3) {
calling fun(2) {
calling fun(1) {
calling fun(0) {
N>0 found.
}
printed 0
calling second fun(-1) {
N>0 found.
}
}
printed 1
calling second fun(0) {
N>0 found.
}
}
printed 2
calling second fun(1) {
calling fun(0) {
N>0 found.
}
printed 0
calling second fun(-1) {
N>0 found.
}
}
}
Is This Answer Correct ? | 27 Yes | 12 No |
What is the output of the program given below main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }
abcdedcba abc cba ab ba a a
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
plz send me all data structure related programs
why the range of an unsigned integer is double almost than the signed integer.
There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange
Write a program to implement the motion of a bouncing ball using a downward gravitational force and a ground-plane friction force. Initially the ball is to be projected in to space with a given velocity vector
#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }
void main() { static int i=5; if(--i){ main(); printf("%d ",i); } }
#define a 10 void foo() { #undef a #define a 50 } int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } explain the answer