#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 |
main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }
main() { char *p="GOOD"; char a[ ]="GOOD"; printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p)); printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a)); }
programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h
write a program in c to merge two array
main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }
Is it possible to type a name in command line without ant quotes?
void main() { static int i=5; if(--i){ main(); printf("%d ",i); } }
main() { int i; i = abc(); printf("%d",i); } abc() { _AX = 1000; }
void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(“%d”, i); }
main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }
main() { char *p="hai friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); }
void main() { int c; c=printf("Hello world"); printf("\n%d",c); }